#SRD0000065. Thi bắn cung Robin Hood (Robin Hood Archery)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Thi bắn cung Robin Hood (Robin Hood Archery)
Robin Hood Archery
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are targets with scores . Robin Hood and the Sheriff alternate choosing an unused target, adding its score to their own total; Robin Hood moves first. Both play optimally. For every inclusive range , consider a separate game on only those targets. Print YES if the Sheriff can avoid losing (win or tie) with optimal play, otherwise NO.
Every query starts a fresh game with both scores reset to zero, and only the selected range of targets is available. Previous queries do not change future games.
Input
First line: ; second line: integers ; then query lines . No leading is used.
Output
For each query print YES or NO on its own line.
Subtasks
- Subtask 1 (10 points): ; ; ; .
- Subtask 2 (20 points): ; ; ; .
- Subtask 3 (25 points): ; ; ; .
- Subtask 4 (45 points): ; ; ; .
Examples
Input
3 3
1 2 2
1 2
1 3
2 3
Output
NO
NO
YES
Explanation
For with scores , Robin Hood takes and wins. In , the unmatched score prevents a tie. In , the two targets both score , so the players tie and the answer is YES.