Submission #384659

#TimeUsernameProblemLanguageResultExecution timeMemory
384659zoooma13Hacker (BOI15_hac)C++14
20 / 100
435 ms22344 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n ,sum = 0; scanf("%d",&n); vector <int> a(n); for(int&i : a) scanf("%d",&i) ,sum += i; a.insert(a.end() ,a.begin() ,a.end()); vector <int> b(n); for(int i=0; i<n/2; i++) b[0] += a[i]; for(int i=1; i<n; i++) b[i] = b[i-1] - a[i-1] + a[i+n/2-1]; b.insert(b.end() ,b.begin() ,b.end()); multiset <int> ms; for(int i=0; i<n/2; i++) ms.insert(b[i]); int ans = sum - *ms.rbegin(); for(int i=0; i<n; i++){ ms.erase(ms.find(b[i])); ms.insert(b[i+n/2]); ans = max(ans ,sum - *ms.rbegin()); } printf("%d\n",ans); }

Compilation message (stderr)

hac.cpp: In function 'int main()':
hac.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
hac.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |         scanf("%d",&i) ,sum += 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...