Problem J. Taotao Picks Apples
时间限制 2000 ms
内存限制 128 MB
There is an apple tree in front of Taotao's house. When autumn comes, $n$ apples on the tree ripen, and Taotao will go to pick these apples.
When Taotao picks apples, Taotao scans these apples from the first one to the last one. If the current apple is the first apple, or it is strictly higher than the previously picked one, then Taotao will pick this apple; otherwise, he will not pick.
Given the heights of these apples $h_1, h_2, \cdots, h_n$, you are required to answer some independent queries. Each query is two integers $p, q$, which asks the number of apples Taotao would pick, if the height of the $p$-th apple were $q$ (instead of $h_p$). Can you answer all these queries?
输入数据
输出数据
For each query, display the answer in a single line.
样例输入
复制
1
5 3
1 2 3 4 4
1 5
5 5
2 3
样例输出
样例说明
For the first query, the heights of the apples were 5, 2, 3, 4, 4, so Taotao would only pick the first apple. For the second query, the heights of the apples were 1, 2, 3, 4, 5, so Taotao would pick all these five apples. For the third query, the heights of the apples were 1, 3, 3, 4, 4, so Taotao would pick the first, the second and the fourth apples.
$ Mathjax font initiator $