Submission #1135309

#TimeUsernameProblemLanguageResultExecution timeMemory
1135309nuutsnoynton도넛 (JOI14_ho_t3)C++20
100 / 100
246 ms1972 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n, m, r, x, y, i, j, ans,s, lo, hi, mid, sum, t; cin >> n; ll a[n + 2], pre[n + 2]; pre[0] = 0; ans = 0; for (i = 1; i <= n; i ++) cin >> a[i], pre[i] = pre[i - 1] + a[i]; for (i = 1; i <= n; i ++) { lo = 1; hi = 1e18; while (lo < hi) { mid = (lo + hi)/2; sum =pre[n]; s = lower_bound(pre + 1, pre + n + 1, pre[i - 1] + mid) - pre; if ( s > n) { hi = mid; continue; } s ++; // cout << s << "S"; r = lower_bound(pre + 1, pre + n + 1, pre[s - 1] + mid) - pre; if ( r > n) { hi = mid; continue; } sum -= (pre[r ] - pre[i - 1]); //cout << mid << " " << sum << " " << r << endl; if( sum < mid) hi = mid; else lo = mid + 1; } ans = max(ans, lo); } cout << ans - 1 << 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...