| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 5 초 | 2048 MB | 116 | 10 | 9 | 8.257% |
Aoi has $N$ cards numbered from $1$ to $N$. Each card has a positive integer written on it. The integer written on the card $i$ ($1 ≤ i ≤ N$) is $A_i$.
Aoi is going to play a game $Q$ times using the cards and a blackboard. The $j$-th game ($1 ≤ j ≤ Q$) she plays consists of the following steps.
For each game, you want to know the maximum number of uiro pieces Aoi can eat.
Given the information about cards and games, write a program that, for each game, calculates the maximum number of uiro pieces Aoi can eat.
Read the following data from the standard input.
$N$
$A_1$ $A_2$ $\cdots$ $A_N$
$Q$
$L_1$ $R_1$
$L_2$ $R_2$
$\vdots$
$L_Q$ $R_Q$
Write $Q$ lines to the standard output. In the $j$-th line ($1 ≤ j ≤ Q$), output the maximum number of uiro pieces Aoi can eat in the $j$-th game.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 3 | $N ≤ 20$, $Q ≤ 20$. |
| 2 | 5 | $N ≤ 300$, $Q ≤ 20$. |
| 3 | 7 | $N ≤ 5\,000$, $Q ≤ 20$. |
| 4 | 15 | $Q ≤ 20$. |
| 5 | 21 | $A_i ≤ 2$ ($1 ≤ i ≤ N$). |
| 6 | 29 | $A_i ≤ 20$ ($1 ≤ i ≤ N$). |
| 7 | 20 | No additional constraints. |
5 3 4 7 2 8 2 1 3 4 4
1 0
One possible sequence of actions in the first game is as follows:
In this case, the number of uiro pieces Aoi eats in the first game is $1$. It can be proven that the number of uiro pieces Aoi eats in the first game does not exceed $1$. Therefore, you should output $1$.
One possible sequence of actions in the second game is as follows:
In this case, the number of uiro pieces Aoi eats in the second game is $0$. It can be proven that the number of uiro pieces Aoi eats in the second game does not exceed $0$. Therefore, you should output $0$.
This sample input satisfies the constraints of subtasks 1, 2, 3, 4, 6, and 7.
14 1 2 2 1 2 1 1 2 1 2 2 1 1 1 5 1 2 1 14 5 11 3 12 4 7
0 8 4 6 2
One possible sequence of actions in the first game is as follows:
In this case, the number of uiro pieces Aoi eats in the first game is $0$. It can be proven that the number of uiro pieces Aoi eats in the first game does not exceed $0$. Therefore, you should output $0$.
This sample input satisfies the constraints of all subtasks.
8 16 23 45 76 43 97 12 43 7 1 8 3 7 2 7 4 5 5 8 2 6 3 5
3 2 2 1 2 2 1
This sample input satisfies the constraints of subtasks 1, 2, 3, 4, and 7.