Problem | Verdict | Lang | Time | Best | Rank | Submit Time |
---|---|---|---|---|---|---|
| discuss11264 - | Accepted | C++11 | 0.000 | 0.000 | 1940 | 1 mins ago |
#include<bits/stdc++.h>
using namespace std;
int t, n;
int a[1000111];
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> t;
while(t--){
cin >> n;
for(int i=1; i<=n; i++)
cin >> a[i];
if (n<3) cout<<n<<"\n";
else{
int cnt= 1;
int s= a[1];
for(int i=2; i<n; i++)
if (s + a[i] < a[i+1]){
cnt++;
s += a[i];
}
cout<<cnt+1<<"\n";
}
}
}
No comments:
Post a Comment