Submission #542411

#TimeUsernameProblemLanguageResultExecution timeMemory
542411pokmui9909도넛 (JOI14_ho_t3)C++17
50 / 100
3 ms660 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; ll N; ll A[100005]; ll S[100005]; int main(){ cin.tie(0) -> sync_with_stdio(false); cin >> N; for(int i = 1; i <= N; i++){ cin >> A[i]; A[i + N] = A[i]; } for(int i = 1; i <= 2 * N; i++){ S[i] = S[i - 1] + A[i]; } ll L = 1, R = 1, ans = 0; while(L <= R && L <= N && R <= 2 * N && R - L + 1 <= N){ ll V = S[R] - S[L - 1]; ll idx = upper_bound(S + R + 1, S + L + N, S[R] + V) - S; if(S[L + N - 1] - S[idx] >= V){ ans = max(ans, V); R++; } else { L++; } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...