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;
void testCase() {
int n;
cin >> n;
vector<int> a(n + 1);
for (int i = 1; i <= n; ++i) {
cin >> a[i];
}
int best = 1;
for (int pref = 1; pref <= n; ++pref) {
int64_t last = 0;
for (int i = 1; i <= pref; ++i) {
last += a[i];
}
int64_t sum = 0;
int cnt = 1;
bool ok = true;
for (int i = pref + 1; i <= n; ++i) {
sum += a[i];
if (sum >= last) {
cnt += 1;
sum = 0;
} else {
if (i == n) {
ok = false;
}
}
}
if (ok) {
best = max(best, cnt);
}
}
cout << best << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int tests = 1;
for (int tc = 0; tc < tests; ++tc) {
testCase();
}
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... |