Submission #789804

#TimeUsernameProblemLanguageResultExecution timeMemory
789804UmairAhmadMirzaHacker (BOI15_hac)C++14
0 / 100
1 ms340 KiB
/*********************ALLAH HO AKBAR***********************/ /************HAZRAT MUHAMMAD (Peace be upon him)***********/ #include <bits/stdc++.h> using namespace std; #define int long long int const N=1e6+5; int pre[N]; int arr[N]; int n; signed main(){ ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); cin>>n; int sm=0; for (int i = 1; i <=n; ++i){ cin>>arr[i]; sm+=arr[i]; } for (int i = 1; i <=n; ++i) arr[i+n]=arr[i]; int k=(n/2)+(n%2); for (int i = 1; i <=2*n; ++i) pre[i]=pre[i-1]+arr[i]; vector<pair<int,int>> v; for (int i = 1; i <=n; ++i) { int chunk=pre[(i+k)-1]-pre[i-1]; int chunk2=sm-chunk; if(chunk>=chunk2) v.push_back({chunk-chunk2,chunk}); } sort(v.begin(), v.end()); cout<<v[0].second<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...