Submission #31088

#TimeUsernameProblemLanguageResultExecution timeMemory
31088nibnalinHacker (BOI15_hac)C++14
100 / 100
693 ms17676 KiB
#include <iostream> #include <cstdio> #include <vector> #include <set> using namespace std; const int maxn = int(5e5)+5, inf = int(1e9)+5; int n, A[maxn], v[maxn]; inline int mod(int x) { return ((x%n)+n)%n; } int main(void) { scanf("%d", &n); for(int i = 0;i < n;i++) scanf("%d", &A[i]); int sz = n/2+n%2; for(int i = 0;i < sz;i++) v[0] += A[i]; for(int i = 1;i < n;i++) { v[i] = v[i-1]+A[mod(i+sz-1)]-A[i-1]; } set<pair<int, int>> S; for(int i = 0;i < sz;i++) S.insert({v[mod(0-i)], mod(0-i)}); int res = S.begin()->first; for(int i = 0;i < n;i++) { S.erase({v[mod(i-sz)], mod(i-sz)}), S.insert({v[i], i}); res = max(res, S.begin()->first); } printf("%d\n", res); }

Compilation message (stderr)

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