Submission #522903

#TimeUsernameProblemLanguageResultExecution timeMemory
522903Alex_tz307Bigger segments (IZhO19_segments)C++17
0 / 100
0 ms204 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...