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;
const int md = 1e6 + 10;
int a[md];
int n;
int main() {
//freopen("test.in", "r", stdin);
ios_base::sync_with_stdio(0);
cin >> n;
for(int i = 1; i <= n; i++)
cin >> a[i];
int l = 1, r = n, vL = a[1], vR = a[n], cnt = 0;
while (l <= r) {
if (vL == vR) {
vL = a[++l];
vR = a[--r];
} else if (vL < vR) {
cnt++;
vL += a[++l];
} else {
cnt++;
vR += a[--r];
}
}
cout << cnt;
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... |