시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
4 초 | 1024 MB | 37 | 16 | 8 | 29.630% |
JOI-kun has $N$ fishes, numbered from $1$ to $N$. The size of the fish $i$ ($1 ≤ i ≤ N$) is $A_i$.
When we grow fish, we have to pay attention to the following fact: if we have two nearby fishes, one fish eats the other fish as time passes. Here, two fishes are nearby if there is no fish between them. More precisely, if the size of the fish $x$ is larger than or equal to the size of the fish $y$, and the fish $x$ and the fish $y$ are nearby, then the fish $x$ eats the fish $y$, and the size of $x$ becomes the sum of the original size of $x$ and the size of $y$. If the fish $x$ and the fish $y$ have the same size, any one of them may eat the other.
JOI-kun will grow fishes for $Q$ days. To kill time, he does the following thought experiment. On the $j$-th day ($1 ≤ j ≤ Q$), JOI-kun takes one of the following actions.
Write a program which, given information of JOI-kun’s fishes and JOI-kun’s plan, calculates the number of possible indices of surviving fishes for each action of Type 2 in order to determine whether JOI-kun’s thought is correct or not. Note that this is just a thought experiment. Please be assured that no fishes are eaten actually.
Read the following data from the standard input. Given values are all integers.
$\begin{align*}& N \\ & A_1 \, A_2 \, \cdots \, A_N \\ & Q \\ & \text{(Query }1\text{)} \\ & \text{(Query }2\text{)} \\ & \vdots \\ & \text{(Query }Q\text{)} \end{align*}$
Each $\text{(Query }j\text{)}$ ($1 ≤ j ≤ Q$) consists of space separated integers. Let $T_j$ be the first integer of $\text{(Query }j\text{)}$. The content of this line is one of the following.
For each action of Type 2 (i.e., for each $j$ ($1 ≤ j ≤ Q$) with $T_j = 2$), in order, write the number of possible indices of surviving fishes to the standard output. The outputs should be separated by line breaks.
번호 | 배점 | 제한 |
---|---|---|
1 | 5 | $N ≤ 500$, $Q ≤ 500$. |
2 | 8 | $Q = 1$, $T_j = 2$, $L_j = 1$, $R_j = N$ ($1 ≤ j ≤ Q$). |
3 | 12 | $Q ≤ 1\,000$. |
4 | 23 | $T_j = 2$ ($1 ≤ j ≤ Q$). |
5 | 35 | For each $j$ ($1 ≤ j ≤ Q$) with $T_j = 2$, the equalities $L_j = 1$ and $R_j = N$ are satisfied. |
6 | 17 | No additional constraints. |
5 6 4 2 2 6 6 2 1 5 2 1 3 1 3 1 2 2 5 2 1 5 2 2 4
5 2 2 3 1
For $6$ days, JOI-kun takes the following actions.
The results of a thought experiment for the first day are as follows.
This sample input satisfies the constraints of Subtasks 1, 3, 6.
13 10 4 2 5 20 5 4 8 20 10 3 3 7 1 2 1 13
7
This sample input satisfies the constraints of all the subtasks.
12 32 32 4 1 1 1 1 4 4 16 32 128 7 2 1 12 2 2 6 2 8 10 2 1 9 2 3 8 2 5 9 2 2 12
12 1 1 2 6 2 1
This sample input satisfies the constraints of Subtasks 1, 3, 4, 6.
10 2 3 5 10 1 3 4 9 5 2 8 2 1 10 1 10 5 2 1 10 1 4 1000000000 2 1 10 1 8 20 1 4 8 2 1 10
4 6 1 6
This sample input satisfies the constraints of Subtasks 1, 3, 5, 6.