#6. CF与睡眠与蓝色星球
CF与睡眠与蓝色星球
Background
At 3:35 a.m., Atom dragged his roommate into a Codeforces competition. After a fierce battle, he successfully reached the rank of Candidate Master. Just as he was overjoyed, reality presented him with a harsh challenge…
Problem Statement
It’s now 5:35 a.m., and Atom has become a Candidate Master, but he realizes that he’s about to attend Professor E’s class, course S. To avoid failing the course while maximizing his sleep, Atom decides to face the challenge as a Candidate Master.
Course S consists of lessons, each with an importance value . Meanwhile, there are parallel universes, and in each one, Professor E has a specific tolerance value and knows the first class that Atom will sleep through after the Codeforces competition. Professor E will fail Atom if he skips any lesson with an importance value greater than or equal to .
Atom will start sleeping from the -th lesson and will sleep through at least that lesson. He wants to know, in each parallel universe, the maximum number of consecutive lessons he can sleep through without failing. If failing is unavoidable, output all in acm; otherwise, output the maximum number of lessons he can sleep through.
Input
The first line contains two positive integers and , representing the number of lessons and the number of parallel universes .
The second line contains positive integers , representing the importance value of each lesson .
The next lines each contain two positive integers and , representing Professor E’s tolerance value and the lesson index from which Atom starts sleeping .
Output
Output lines, each containing an integer or a string. For each parallel universe:
- If Atom cannot avoid failing, output
all in acm. - Otherwise, output the maximum number of consecutive lessons he can sleep through.
Example
Input
6 4
1 3 6 4 2 9
5 2
7 3
2 4
6 1
Output
1
3
all in acm
2
Constraints
- For of the test cases, .
- For of the test cases, .
相关
在下列比赛中: