#include<bits/stdc++.h>
using namespace std;
deque<int> q;
int ans;
int main(){
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int n,temp;
cin>>n;
for(int i=0;i<n;i++){
cin>>temp;
q.push_back(temp);
}
while(q.size()>1){
if(q.front()==q.back()){
q.pop_front();
q.pop_back();
}
else{
ans++;
if(q.front()>q.back()){
int now=q.back();
q.pop_back();
now+=q.back();
q.pop_back();
q.push_back(now);
}
else{
int now=q.front();
q.pop_front();
now+=q.front();
q.pop_front();
q.push_front(now);
}
}
}
cout<<ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
632 KB |
Output is correct |
2 |
Correct |
27 ms |
888 KB |
Output is correct |
3 |
Correct |
27 ms |
888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
80 ms |
1656 KB |
Output is correct |
2 |
Correct |
101 ms |
2936 KB |
Output is correct |
3 |
Correct |
118 ms |
3320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
174 ms |
3448 KB |
Output is correct |
2 |
Correct |
184 ms |
4856 KB |
Output is correct |
3 |
Correct |
199 ms |
4984 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
218 ms |
4344 KB |
Output is correct |
2 |
Correct |
228 ms |
5496 KB |
Output is correct |
3 |
Correct |
228 ms |
5496 KB |
Output is correct |