0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-08 12:58:48 +00:00

C - Directional Increase

https://codeforces.com/contest/1694/submission/160915609
This commit is contained in:
Baoshuo Ren 2022-06-17 11:06:21 +08:00
parent 84a7cf3651
commit 7010cdd6c6
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

35
Codeforces/1694/C/C.cpp Normal file
View File

@ -0,0 +1,35 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
bool flag = false, ans = true;
int n;
long long sum = 0;
cin >> n;
for (int i = 1, x; i <= n; i++) {
cin >> x;
if ((sum += x) < 0) ans = false;
if (sum == 0) flag = true;
else if (flag) ans = false;
}
cout << (ans && !sum ? "Yes" : "No") << endl;
}
return 0;
}