mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:11:58 +00:00
C - Directional Increase
https://codeforces.com/contest/1694/submission/160915609
This commit is contained in:
parent
84a7cf3651
commit
7010cdd6c6
35
Codeforces/1694/C/C.cpp
Normal file
35
Codeforces/1694/C/C.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user