Submission #49166

#TimeUsernameProblemLanguageResultExecution timeMemory
49166faishol27Hacker (BOI15_hac)C++14
0 / 100
2 ms556 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define PUB push_back int N, defend; ll data[1500005], total = 0, ans = 0; ll prefsum[1500005]; ll hitungScore(int ind){ int strL, finL; int strR, finR; ll scoreDef, scoreL, scoreR; finL = ind-1; strL = finL-defend+1; strR = ind+1; finR = strR+defend-1; scoreL = prefsum[finL]-prefsum[strL-1]; scoreR = prefsum[finR]-prefsum[strR-1]; scoreDef = max(scoreL, scoreR); return total-scoreDef; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N; defend = N/2; for(int i=0;i<N;i++){ cin >> data[i]; total += data[i]; data[i+N] = data[i]; data[i+2*N] = data[i]; } prefsum[0] = data[0]; for(int i=1;i<3*N;i++){ prefsum[i] = data[i]+prefsum[i-1]; } for(int i=N;i<2*N;i++){ ans = max(ans, hitungScore(i)); } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...