Submission #311286

#TimeUsernameProblemLanguageResultExecution timeMemory
311286sofapudenHacker (BOI15_hac)C++14
100 / 100
617 ms17640 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<int> v(n), msa; for(auto &x : v)cin >> x; int cur = 0; for(int i = 0; i < (n+1)/2; ++i){ cur+=v[i]; } msa.push_back(cur); for(int i = 0; i < n-1; ++i){ cur-=v[i]; cur+=v[(i+((n+1)/2))%n]; msa.push_back(cur); } map<int,int> S; for(int i = 0; i < (n+1)/2; ++i){ S[msa[i]]++; } int ans = S.begin()->first; for(int i = 0; i < n-1; ++i){ S[msa[i]]--; if(!S[msa[i]])S.erase(msa[i]); S[msa[(i+((n+1)/2))%n]]++; ans = max(ans,S.begin()->first); } cout << ans << "\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...