Problems
There is a line of cows, initially (i.e. at time
Answer
Out of cows
Input
The first line contains
The next
Output
Output the answer to each query on a separate line.
Subtask
| # | Score | Condition |
|---|---|---|
| #1 | 10 | |
| #2 | 20 | |
| #3 | 30 | |
| #4 | 40 | No additional constraints |
Example #1
4
0 9 0 9 9
3 5 4 5 9
4 5 3 5 9
1 1 3 3 9
10
2
1
1
t = 0 | 0
t = 1 | 0 1
t = 2 | 1 0 2
t = 3 | 0 1 2 3
t = 4 | 1 2 0 3 4
t = 5 | 2 0 1 3 4 5
t = 6 | 0 1 3 2 4 5 6
t = 7 | 1 3 2 0 4 5 6 7
t = 8 | 3 2 0 4 1 5 6 7 8
t = 9 | 2 0 4 1 3 5 6 7 8 9
At t=9 the cows from front to back are [2,0,4,1,3,5,6,7,8,9].
To answer the third query, the cows at positions 3…5
are [1,3,5], and only one of them is in the range 4…5.
Example #2
1
0 1000000000000000000 0 1000000000000000000 1000000000000000000
1000000000000000001