제출 #49114

#제출 시각아이디문제언어결과실행 시간메모리
49114faishol27Hacker (BOI15_hac)C++14
0 / 100
7 ms604 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXE = 1e6+5; int N, dapat; ll data[500005], total = 0, ans = 0, sliding = 0, selisih = MAXE; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N; dapat = (N+1)/2; for(int i=0;i<N;i++){ cin >> data[i]; total += data[i]; } for(int i=0;i<dapat;i++) sliding += data[i]; if(abs(total-2*sliding) < selisih){ ans = max(total-sliding, sliding); selisih = abs(total-2*sliding); } for(int i=1;i<N;i++){ int right = (dapat+i-1)%N; sliding = sliding-data[i-1]+data[right]; if(abs(total-2*sliding) < selisih){ ans = max(total-sliding, sliding); selisih = abs(total-2*sliding); } } 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...