Submission #42647

#TimeUsernameProblemLanguageResultExecution timeMemory
42647XmtosXHacker (BOI15_hac)C++14
100 / 100
575 ms35124 KiB
#include <bits/stdc++.h> using namespace std; int n,v[500005],here[500005],ans; set <pair<int,int> > s; int main() { scanf("%d",&n); for (int i=0;i<n;i++) scanf("%d",&v[i]); int k= (n/2)+(n%2),cur=0; for (int i=0;i<k;i++) cur+=v[i]; for (int i=0;i<n;i++) { int j= (i+k)%n; cur-=v[i]; cur+=v[j]; here[(i+1)%n]=cur; } for (int i=0;i<k;i++) s.insert({here[i],i}); for (int i=0;i<n;i++) { int j= (i+k)%n; s.erase({here[i],i}); s.insert({here[j],j}); ans=max(ans,s.begin()->first); } cout <<ans; return 0; }

Compilation message (stderr)

hac.cpp: In function 'int main()':
hac.cpp:7:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
hac.cpp:9:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&v[i]);
                          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...