This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr)
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e6+5;
long long a[maxn];
int main()
{
fastio;
int n; cin >> n;
for (int i=1; i<=n; ++i)
cin >> a[i];
int i, j, ans=0;
for (i=1, j=n; i<j; )
{
++ans;
if (a[i]<a[j])
{
a[i+1]+=a[i];
++i;
}
else if (a[i]>a[j])
{
a[j-1]+=a[j];
--j;
}
else
++i, --j, --ans;
}
cout << ans;
}
# | 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... |