Submission #554583

# Submission time Handle Problem Language Result Execution time Memory
554583 2022-04-28T19:13:33 Z Soumya1 Hacker (BOI15_hac) C++17
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>
#ifdef __LOCAL__
#include <debug_local.h>
#endif
using namespace std;
const int mxN = 1e6 + 5;
long long a[mxN];
multiset<long long> s;
void testCase() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) a[i + n] = a[i];
  for (int i = 1; i <= n; i++) a[i] += a[i - 1];
  int x = (n + 1) / 2;
  for (int i = x; i < x + x; i++) s.insert(a[i] - a[i - x]);
  long long ans = *s.begin();
  for (int i = x + 1; i <= 2 * n - x + 1; i++) {
    s.erase(s.find(a[i - 1] - a[i - x - 1]));
    s.insert(a[i + x - 1] - a[i - 1]);
    ans = max(ans, *s.begin());
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  testCase();
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -