3081Flip Maximum

3081   Flip Maximum

题目描述

Bob was given an array A consists of N elements.Alice is so clever, she immediately claim that The max sum of consecutive elements is X.(Don’t guarantee it’s correct).

Bob is tricky, he secretly flip one number from x to -x, and say “You are wrong, the max sum is Y”. Now you task is to check whether there is a way to flip one number and make Y > X.

Notice that if all elements are non-positive, the max sum of consecutive elements is 0.

输入格式:

The input contains several test cases.

Each test case contains two positive integers N, X;

The next line contains N integers represent the array A.

(0 < N ≤ 20000)    (-1e9 ≤ A_i ≤ 1e9)    (0    X  ≤ 1e18)

输出格式:

if there is a way to make Y > X, print “YES” ,otherwise print “NO”.

输入样例 复制
5 5
1 -2 3 -4 5
5 100
1 -2 -3 -4 -5
输出样例 复制
YES
NO

说明

Bob can flip -4 to 4, and now the max sum is 3+4+5;

There is another way, He can also flip -2, to make 1+2+3 > 5;

0
3
通过提交
时空限制1000ms/128mb
题目来源
评测方式在线评测
题目类型
难        度