Submission #708516

#TimeUsernameProblemLanguageResultExecution timeMemory
708516WH8Bigger segments (IZhO19_segments)C++14
0 / 100
1 ms316 KiB
#include <bits/stdc++.h> using namespace std; #define iloop(x, n) for (long long i = x; i < n; ++i) #define jloop(x, n) for (long long j = x; j < n; ++j) #define kloop(x, n) for (long long k = x; k < n; ++k) #define dloop(x, n) for (long long d = x; d >= n; --d) #define ll long long #define pll pair<long long, long long> #define pii pair<int, int> #define vi vector<long long> #define mp make_pair #define pb push_back #define f first #define s second #define int long long #define endl '\n' #define debug(x) cout << #x << ": " << x << endl #define FASTIO \ ios::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); int32_t main(){ FASTIO int n; cin >> n; vi v(n); iloop(0, n) cin >> v[i]; int prev = 1, csm = 0, cnt = 0; iloop(0, n){ csm += v[i]; if (csm >= prev){ cnt++; prev = csm; csm = 0; } else if (i == n-1){ cnt = 1; } } prev = INT_MAX, csm = 0; int ans= 0; for (int i = n-1; i >= 0; i--){ csm += v[i]; debug(csm); if (csm <= prev){ ans++; prev = csm; csm = 0; } else if (i == 0){ ans = 1; } } cout << max(ans, cnt); }
#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...