This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |