#BS0000480. Tăng cấp (Level Up)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Tăng cấp (Level Up)
Level Up
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Monocarp starts at level and encounters monsters in order, numbered from to . Monster has level .
An encounter results in a fight if the player's current level does not exceed the monster's level. Otherwise the monster runs away. For a fixed positive integer , the player gains one level immediately after each group of actual fights; fleeing monsters do not contribute to that count.
For each of independent queries , restart at level , set , and determine whether encounter results in a fight.
Input
The first line contains integers , the numbers of monsters and queries.
The second line lists their levels in encounter order.
Each of the following lines contains integers : the monster index and the number of fights per level increase.
Output
Print one line per query in input order: YES for a fight and NO if the monster flees.
Subtasks
- Subtask 1 (20 points): ; ; (); for every query.
- Subtask 2 (30 points): ; ; (); for every query.
- Subtask 3 (50 points): ; ; (); for every query.
Examples
Input
4 6
2 1 2 1
1 1
2 1
3 1
4 2
3 2
4 4
Output
YES
NO
YES
NO
YES
YES
Explanation
The four monster levels are .
- For , the first fight raises the player's level to 2. Monster 2 flees; monster 3 has level 2 and is fought. Thus the first three answers are
YES,NO,YES. - For , fights 1 and 2 raise the player's level to 2. Monster 3 is fought and monster 4 flees, yielding
NOfor andYESfor . - For , the player is still level 1 before encounter 4. All four monsters are fought, so the final answer is
YES.