0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 19:36:28 +00:00
OI-codes/Codeforces/1694/C/C.cpp

36 lines
577 B
C++

#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;
}