Submission #639726

#TimeUsernameProblemLanguageResultExecution timeMemory
639726WunkaHacker (BOI15_hac)C++17
0 / 100
1 ms316 KiB
#include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<int> a(2 * n); int S = 0; for(int i = 0; i < n; i++) { cin >> a[i]; a[i + n] = a[i]; S += a[i]; } vector<int> pref(2 * n + 1, 0); for(int i = 0; i < 2 * n; i++) { pref[i + 1] = pref[i] + a[i]; } int ans = INT_MAX - 5; //cerr << "moves:" << (n + 1) / 2 << '\n'; for(int i = 0; i < n; i++) { int sum = pref[i + (n + 1) / 2] - pref[i]; //cerr << sum << ' ' << S - sum << '\n'; ans = min(ans, abs(sum - (S - sum))); } cout << (ans + S) / 2 << '\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...