Submission #860477

#TimeUsernameProblemLanguageResultExecution timeMemory
860477AlfraganusBigger segments (IZhO19_segments)C++17
0 / 100
0 ms452 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define fs first #define ss second #define str string #define all(a) a.begin(), a.end() #define print(a) \ for (auto x : a) \ cout << x << ' '; \ cout << endl; #define each(x, a) for (auto x : a) void solve() { int n; cin >> n; vector<int> a(n); for(int i = 0; i < n; i ++) cin >> a[i]; int l = 1, r = 1, s = 0, last = a[0], ans = 1; while(l < n and r < n){ while(r < n and last > s) s += a[r], r ++; if(last <= s) ans ++; while(l < r and s - a[l] >= last + a[l]) s -= a[l], last += a[l], l ++; l = r; last = s; s = 0; } cout << ans; } signed main() { ios::sync_with_stdio(0); cin.tie(0); int t = 1; // cin >> t; while (t--) { solve(); cout << endl; } }
#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...