307003: CF1285B. Just Eat It!
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Just Eat It!
题意翻译
### 题意简述 给定长度为 $n$ 的数列 $a=[a_1,a_2,...,a_n]$。 Yasser 会选择所有的 $n$ 个数,并算出它们的和 $\sum a_i$。 Adel 会选择两个正整数 $l,r(1\leq l \leq r \leq n)$,并算出 $\sum_{i=l}^{r} a_i$。Adel 不能选择 $l=1,r=n$。 如果 Yasser 算出的和在任意情况下(即 Adel 选取任意的 $l,r$ 都是如此)**严格大于** Adel 算出的,那么 Yasser 会开心。否则 Yasser 不会开心。 请你判断 Yasser 是否开心。 ### 输入格式 **本题有多组数据**。 第一行一个正整数 $t(1\leq t \leq 10^4)$,表示数据的组数。 对于每组数据,第一行一个正整数 $n(2\leq n \leq 10^5)$。 接下来一行 $a_1,a_2,...,a_n(-10^{9} \leq a_i \leq 10^9)$。 保证 $\sum n$ 不会超过 $10^5$。 ### 输出格式 对于每组数据,如果 Yasser 会开心,输出 `YES`,否则输出 `NO`。 翻译贡献者 U108949题目描述
Today, Yasser and Adel are at the shop buying cupcakes. There are $ n $ cupcake types, arranged from $ 1 $ to $ n $ on the shelf, and there are infinitely many of each type. The tastiness of a cupcake of type $ i $ is an integer $ a_i $ . There are both tasty and nasty cupcakes, so the tastiness can be positive, zero or negative. Yasser, of course, wants to try them all, so he will buy exactly one cupcake of each type. On the other hand, Adel will choose some segment $ [l, r] $ $ (1 \le l \le r \le n) $ that does not include all of cupcakes (he can't choose $ [l, r] = [1, n] $ ) and buy exactly one cupcake of each of types $ l, l + 1, \dots, r $ . After that they will compare the total tastiness of the cupcakes each of them have bought. Yasser will be happy if the total tastiness of cupcakes he buys is strictly greater than the total tastiness of cupcakes Adel buys regardless of Adel's choice. For example, let the tastinesses of the cupcakes be $ [7, 4, -1] $ . Yasser will buy all of them, the total tastiness will be $ 7 + 4 - 1 = 10 $ . Adel can choose segments $ [7], [4], [-1], [7, 4] $ or $ [4, -1] $ , their total tastinesses are $ 7, 4, -1, 11 $ and $ 3 $ , respectively. Adel can choose segment with tastiness $ 11 $ , and as $ 10 $ is not strictly greater than $ 11 $ , Yasser won't be happy :( Find out if Yasser will be happy after visiting the shop.输入输出格式
输入格式
Each test contains multiple test cases. The first line contains the number of test cases $ t $ ( $ 1 \le t \le 10^4 $ ). The description of the test cases follows. The first line of each test case contains $ n $ ( $ 2 \le n \le 10^5 $ ). The second line of each test case contains $ n $ integers $ a_1, a_2, \dots, a_n $ ( $ -10^9 \le a_i \le 10^9 $ ), where $ a_i $ represents the tastiness of the $ i $ -th type of cupcake. It is guaranteed that the sum of $ n $ over all test cases doesn't exceed $ 10^5 $ .
输出格式
For each test case, print "YES", if the total tastiness of cupcakes Yasser buys will always be strictly greater than the total tastiness of cupcakes Adel buys regardless of Adel's choice. Otherwise, print "NO".
输入输出样例
输入样例 #1
3
4
1 2 3 4
3
7 4 -1
3
5 -5 5
输出样例 #1
YES
NO
NO