Submission #1029007

#TimeUsernameProblemLanguageResultExecution timeMemory
1029007amine_arouaHacker (BOI15_hac)C++17
40 / 100
1044 ms1880 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int n ; cin>>n; vector<int> v(n); vector<int> pref(n); for(int i = 0 ;i < n ; i++) { cin>>v[i]; pref[i] = v[i]; if(i) pref[i]+=pref[i - 1]; } int best = 0; for(int shift = 0 ; shift < n ; shift++) { int ans = LLONG_MAX; for(int i = 1 + n/2 ; i <= n ; i++) { int j = ((i + shift) % n); int k = (j + (n+1)/2 - 1 + n)%n; if(k >= j) ans = min(ans , pref[k] - (j ? pref[j - 1] : 0)); else ans = min(ans , pref[n - 1] - (j ? pref[j - 1] : 0) + pref[k]); } best = max(best , ans); } cout<<best<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...