#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=1e5+100;
bool visited[maxn];
int n;
vector<int> v;
void solve(int l,int r,int s){
if(l==r){
visited[l]=true;
return;
}
if(s-v[l]>=v[l]){
solve(l+1,r,s-v[l]);
}
if(s-v[r]>=v[r]){
solve(l,r-1,s-v[r]);
}
}
signed main(){
int n;
cin>>n;
v.resize(n);
for(int i=0;i<n;i++){
cin>>v[i];
}
int s=0;
for(auto x:v) s+=x;
solve(0,n-1,s);
int q;
cin>>q;
while(q--){
int t,l,r;
cin>>t>>l>>r;
int ans=0;
for(int i=0;i<n;i++) ans+=visited[i];
cout<<ans<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
4070 ms |
6484 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
4070 ms |
6484 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
4070 ms |
6484 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |