#Lutece3350. Sleepy Capoo
Sleepy Capoo
Description
Capoo the cat worm is studying at Cat Tech University. There are classes in a week, but Capoo often stays up all night playing video games, so he skips classes during the day to catch up on sleep. However, to avoid failing, Capoo plans to attend classes to earn participation points. Attending the -th class will increase Capoo's participation points by . When Capoo decides to attend classes, he will wake up before the -th class of this week and then spend a continuous period of time attending some classes over the next classes (possibly including classes from the next week, and not necessarily starting from the -th class).
Now, Capoo has plans. For each plan, he wakes up before the -th class and attempts to earn exactly participation points. However, Capoo isn't sure if his plan will succeed, so as his roommate, your task is to help him determine whether each plan is executable.
Input
The first line contains two integers (), representing the number of classes in a week and the number of Capoo's plans, respectively.
The second line contains integers, representing (), the participation points Capoo can gain from each class.
The next lines each contain two integers (), representing Capoo's plans.
Output
Output lines. For each plan, print YES
if it is executable; otherwise, print NO
.
Samples
6 4
1 2 2 1 1 0
1 8
3 5
4 5
3 3
NO
YES
YES
YES
Resources
电子科技大学第十五届 ACM 趣味程序设计竞赛