101953: [AtCoder]ABC195 D - Shipping Center

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $400$ points

Problem Statement

We have $N$ pieces of baggage called Baggage $1$ through $N$, and $M$ boxes called Box $1$ through $M$.

Baggage $i$ has a size of $W_i$ and a value of $V_i$.

Box $i$ can contain a piece of baggage whose size of at most $X_i$. It cannot contain two or more pieces of baggage.

You will be given $Q$ queries. In each query, given two integers $L$ and $R$, solve the following problem:

  • Problem: Out of the $M$ boxes, $R-L+1$ boxes, Box $L,L+1,\ldots,R$, have become unavailable. Find the maximum possible total value of a set of baggage that we can put into the remaining boxes simultaneously.

Constraints

  • $1 \leq N \leq 50$
  • $1 \leq M \leq 50$
  • $1 \leq Q \leq 50$
  • $1 \leq W_i \leq 10^6$
  • $1 \leq V_i \leq 10^6$
  • $1 \leq X_i \leq 10^6$
  • $1 \leq L \leq R \leq M$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

$N$ $M$ $Q$
$W_1$ $V_1$
$\vdots$
$W_N$ $V_N$
$X_1$ $\ldots$ $X_M$
$\mathrm{Query}_1$
$\vdots$
$\mathrm{Query}_Q$

Each Query is in the following format:

$L$ $R$

Output

Print $Q$ lines.

The $i$-th line should contain the answer to the problem described by $\mathrm{Query}_i$.


Sample Input 1

3 4 3
1 9
5 3
7 8
1 8 6 9
4 4
1 4
1 3

Sample Output 1

20
0
9

In the $1$-st query, only Box $4$ is unavailable. By putting Baggage $1$ into Box $1$, Baggage $3$ into Box $2$, and Baggage $2$ into Box $3$, we can put all baggage into boxes, making the total value of baggage in boxes $20$.

In the $2$-nd query, all boxes are unavailable; the answer is $0$.

In the $3$-rd query, only Box $4$ is available. By putting Baggage $1$ into Box $4$, we can make the total value of baggage in boxes $9$, which is the maximum possible result.

Input

题意翻译

有编号为 $1$ 到 $N$ 的 $N$ 个行李和编号为 $1$ 到 $M$ 的 $M$ 个箱子。 行李 $i$ 的大小是 $W_i$,价值是 $Vi$。 箱子 $i$ 可以放入大小 $X_i$ 以下的行李。$1$ 个箱子不能放 $2$ 件以上的行李。 给出 $Q$ 个查询。每个查询都会给出 $2$ 个整数 $L,R$,请解决下面的问题。 问题: 在这 $M$ 个箱子中,区间 $[L,R]$ 的 $R - L+ 1$ 个箱子不能使用了。请求剩下的箱子里能放入的行李的总价值的最大值。

加入题单

上一题 下一题 算法标签: