Untitled
unknown
plain_text
a month ago
2.4 kB
46
Indexable
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
const int MOD = 1e9 + 7;
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << " "; _print(x); cerr << endl;
#else
#define debug(x)
#endif
void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(long double t) { cerr << t; }
void _print(double t) { cerr << t; }
void _print(unsigned long long t) { cerr << t; }
template <class T, class V> void _print(pair<T, V> p);
template <class T> void _print(vector<T> v);
template <class T> void _print(set<T> v);
template <class T, class V> void _print(map<T, V> v);
template <class T> void _print(multiset<T> v);
template <class T, class V> void _print(pair<T, V> p) { cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}"; }
template <class T> void _print(vector<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }
template <class T> void _print(set<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }
template <class T> void _print(multiset<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }
template <class T, class V> void _print(map<T, V> v) { cerr << "[ "; for (auto i : v) { _print(i); cerr << " "; } cerr << "]"; }
// Functions start here
int power(int A, int B) {
if (B == 0) return 1;
int res = (power(A, B / 2) % MOD);
if (B % 2) return ((res * res) * A) % MOD;
else return (res * res) % MOD;
}
void SieveOfEratosthenes(int n) {
bool prime[n + 1];
memset(prime, true, sizeof(prime));
for (int p = 2; p * p <= n; p++) {
if (prime[p] == true) {
for (int i = p * p; i <= n; i += p)
prime[i] = false;
}
}
}
// Main function
signed main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("Error.txt", "w", stderr);
#endif
int t;
cin >> t;
while (t--) {
debug("STTTTTTTTTTTTTTTTTTTTTTTTT")
int n;
cin >> n;
vector<int> a(n);
for(int &i:a)cin>>i;
int sum =0,ans=0;
for(int i = n-1;i>=0;i--){
a[i] += sum;
if(a[i]>0)ans++;
sum = max(sum,a[i]);
}
cout << ans <<endl;
}
return 0;
}Editor is loading...
Leave a Comment