Submission #807854

#TimeUsernameProblemLanguageResultExecution timeMemory
807854nononoHacker (BOI15_hac)C++14
100 / 100
62 ms10696 KiB
#include <bits/stdc++.h> using namespace std; const int mxN = 1e6 + 5; int n, m; int a[mxN]; int b[mxN]; int main() { #define taskname "" if(fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } cin.tie(0)->sync_with_stdio(0); cin >> n; for(int i = 1; i <= n; i ++) { cin >> a[i]; a[n + i] = a[i]; } m = (n + 1) / 2; for(int i = 1; i <= 2 * n; i ++) { b[i] += b[i - 1] + a[i]; if(i >= m) b[i] -= a[i - m]; } deque<int> dq; int result = 0; for(int i = m; i <= 2 * n; i ++) { while(!dq.empty() && i - dq.front() >= m) dq.pop_front(); while(!dq.empty() && b[dq.back()] >= b[i]) dq.pop_back(); dq.push_back(i); if(i >= 2 * m - 1) result = max(result, b[dq.front()]); } cout << result << "\n"; return 0; }

Compilation message (stderr)

hac.cpp: In function 'int main()':
hac.cpp:14:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
hac.cpp:15:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...