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 pii pair<int,int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define ll long long
const int N = 1000010;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9+7;
int v[N];
int f(int x,int y,int sumx,int sumy) {
if(y<=x) return 0;
if(v[x]+sumx==v[y]+sumy) return f(x+1,y-1,0,0);
if(v[x]+sumx<v[y]+sumy) {
return 1+f(x+1,y,sumx+v[x],sumy);
} else {
return 1+f(x,y-1,sumx,sumy+v[y]);
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
for(int i=1;i<=n;i++) {
cin>>v[i];
}
cout<<f(1,n,0,0)<<"\n";
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... |