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;
#define endl "\n"
typedef long long int ll;
int arr[1000009];
int solve(int i,int j){
if(i>=j) return 0;
if(arr[i]==arr[j]) {
return solve(i+1,j-1);
}
else if(arr[i]>arr[j]) {
arr[j-1]+=arr[j];
return 1+solve(i,j-1);
}
else {
arr[i+1]+=arr[i];
return 1+solve(i+1,j);
}
}
int main()
{
ios_base:: sync_with_stdio(false); cin.tie(0);
int n; cin>>n;
for(int i=1; i<=n; i++) cin>>arr[i];
cout<<solve(1,n)<<endl;
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... |