Submission #311277

#TimeUsernameProblemLanguageResultExecution timeMemory
311277sofapudenHacker (BOI15_hac)C++14
20 / 100
503 ms14072 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/2; ++i){ cur+=v[i]; } msa.push_back(cur); int tot = v[n-1]; for(int i = 0; i < n-1; ++i){ tot+=v[i]; cur-=v[i]; cur+=v[(i+(n/2))%n]; msa.push_back(cur); } set<int> S; for(int i = 0; i < n/2; ++ i){ S.insert(msa[i]); } int ans = *S.rbegin(); for(int i = 0; i < n-1; ++i){ S.erase(msa[i]); S.insert(msa[(i+(n/2))%n]); ans = min(ans,*S.rbegin()); } cout << tot-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...