PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000480. Tăng cấp (Level Up)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tăng cấp (Level Up)

Level Up

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Monocarp starts at level 11 and encounters nn monsters in order, numbered from 11 to nn. Monster ii has level aia_i.

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 kk, the player gains one level immediately after each group of kk actual fights; fleeing monsters do not contribute to that count.

For each of qq independent queries (i,x)(i,x), restart at level 11, set k=xk=x, and determine whether encounter ii results in a fight.

Input

The first line contains integers n,qn,q, the numbers of monsters and queries.

The second line lists their levels a1,a2,…,ana_1,a_2,\ldots,a_n in encounter order.

Each of the following qq lines contains integers i,xi,x: 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): 1≤n≤501\le n\le 50; 1≤q≤501\le q\le 50; 1≤ai≤2000001\le a_i\le 200000 (1≤i≤n1\le i\le n); 1≤i,x≤n1\le i,x\le n for every query.
  • Subtask 2 (30 points): 1≤n≤30001\le n\le 3000; 1≤q≤30001\le q\le 3000; 1≤ai≤2000001\le a_i\le 200000 (1≤i≤n1\le i\le n); 1≤i,x≤n1\le i,x\le n for every query.
  • Subtask 3 (50 points): 1≤n≤2000001\le n\le 200000; 1≤q≤2000001\le q\le 200000; 1≤ai≤2000001\le a_i\le 200000 (1≤i≤n1\le i\le n); 1≤i,x≤n1\le i,x\le n 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 2,1,2,12,1,2,1.

  • For x=1x=1, 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 x=2x=2, fights 1 and 2 raise the player's level to 2. Monster 3 is fought and monster 4 flees, yielding NO for (4,2)(4,2) and YES for (3,2)(3,2).
  • For x=4x=4, the player is still level 1 before encounter 4. All four monsters are fought, so the final answer is YES.