Submission #732077

# Submission time Handle Problem Language Result Execution time Memory
732077 2023-04-28T11:01:19 Z sleepntsheep Hacker (BOI15_hac) C++17
0 / 100
1 ms 308 KB
#include <bits/stdc++.h>
using namespace std;

#define N 500005
int n, a[N], b[N];

using ll = long long;
ll ring_query2(int l, int r)
{
    if (l > 0 && r <= n) return b[r] - b[l-1];
    if (r > 0 && l <= 0) return ring_query2(1, r) + ring_query2(l + n, n);
    if (l > 0 && l <= n && r > n) return ring_query2(l, n) + ring_query2(1, r - n);
    printf("%d %d\n", l, r); assert(0);
}
ll z = 0;

ll ring_query(int l, int r)
{
    ll res = ring_query2(l, r);
    return res;
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", a+i), b[i] = b[i-1] + a[i];

    int bsz = n % 2 ? (n + 1) / 2 : n / 2;
    for (int i = 1; i <= n; i++) z = max(z, min(ring_query(i - bsz + 1, i), ring_query(i, i + bsz - 1)));

    printf("%lld", z);

    return 0;
}

Compilation message

hac.cpp: In function 'int main()':
hac.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
hac.cpp:26:39: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     for (int i = 1; i <= n; i++) scanf("%d", a+i), b[i] = b[i-1] + a[i];
      |                                  ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -