Submission #1101120

#TimeUsernameProblemLanguageResultExecution timeMemory
1101120KodikHacker (BOI15_hac)C++17
100 / 100
274 ms26188 KiB
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second typedef long long ll; typedef long double ld; #define int ll int mod = 998244353; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<int> arr(2*n+1, 0); multiset<int> vals; int sz = (n+1)/2; for(int i = 1; i <= n; ++i){ cin >> arr[i]; arr[i+n] = arr[i]; } for(int i = 1; i <= 2*n; ++i){ arr[i] += arr[i-1]; } int ans = 0; vector<int> ret(n+1 ,INT_MAX); for(int i = 1; i <= 2*n;++i){ if(i+sz-1<=2*n){ vals.insert(arr[i+sz-1]-arr[i-1]); } if(i>sz){ vals.erase(vals.find(arr[i-1]-arr[i-1-sz])); } int prev = ((i-1)%n)+1; ret[prev] = min(ret[prev], *vals.begin()); } for(int i = 1; i <= n;++i){ ans = max(ans, ret[i]); } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...