ural 1247. Check a Sequence

1247. Check a Sequence

Time limit: 0.5 second
Memory limit: 64 MB
There is a sequence of integer numbers A1, A2, …, AS, and a positive integer N. It's known that all elements of the sequence {Ai} satisfy the restriction 0 ≤ Ai ≤ 100. Moreover, it's known that the sum of all elements of the sequence is equal to S + N. You are to write a program that given a sequence {Ai} and a number N will answer the question: is it true that for all 1 ≤ i ≤ j ≤ S the following inequality holds:
Ai + Ai+1 + … + Aj ≤ (j – i + 1) + N ?

Input

The first input line contains two separated with a space positive numbers S and N that do not exceed 30000. Then follow S lines with one number in a line that are elements of the sequence {Ai}.

Output

Output "YES", if the mentioned above inequality holds for all the values of the parameters i and j, and "NO" otherwise.

Samples

inputoutput
4 3
2
3
0
2
YES
4 5
1
0 
5
3
NO
Problem Author: Alexander Mironenko
Problem Source: Ural State University Personal Programming Contest, March 1, 2003
posted @ 2015-11-14 16:12  yanzx6  阅读(186)  评论(0编辑  收藏  举报