Submission #883256

#TimeUsernameProblemLanguageResultExecution timeMemory
883256OAleksaBigger segments (IZhO19_segments)C++14
0 / 100
1 ms604 KiB
#include<bits/stdc++.h> using namespace std; #define f first #define s second #define int long long const int maxn = 2010; const int inf = 1e15; int a[maxn], l, r, n, p[maxn]; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int tt = 1; //cin >> tt; while (tt--) { int n; cin >> n; vector<int> a(n); for (int i = 0;i < n;i++) cin >> a[i]; int sm = a[0], c = 0, l = 1, r = 1; vector<pair<int, int>> ans; ans.push_back({0, 0}); while (r < n) { c += a[r]; if (c < sm) { r++; continue; } assert(c >= sm); while (sm + a[l] <= c - a[l]) { sm += a[l]; c -= a[l]; l++; } ans.push_back({l, r}); l = r + 1; r++; sm = c; c = 0; } cout << ans.size(); } 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...