#x1038. CF797E Array Queries
CF797E Array Queries
Array Queries
题面翻译
- 给定长度为 的序列 。 次询问。
- 每次询问给出 。您要不断地执行操作 ,直到 为止。询问的答案为操作次数。
- ,,。
题目描述
is an array of positive integers, all of which are not greater than .
You have to process queries to this array. Each query is represented by two numbers and . Several operations are performed in each query; each operation changes to . There operations are applied until becomes greater than . The answer to the query is the number of performed operations.
输入格式
The first line contains one integer .
The second line contains integers — elements of ( for each from to ).
The third line containts one integer .
Then lines follow. Each line contains the values of and for corresponding query .
输出格式
Print integers, th integer must be equal to the answer to th query.
样例 #1
样例输入 #1
3
1 1 1
3
1 1
2 1
3 1
样例输出 #1
2
1
1
提示
Consider first example:
In first query after first operation , after second operation .
In next two queries is greater than after the first operation.