Submission #732078

#TimeUsernameProblemLanguageResultExecution timeMemory
732078sleepntsheepHacker (BOI15_hac)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h>
using namespace std;

#define N 500005
int n;

using ll = long long;

ll z = 0;
ll a[N], b[N];

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 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("%lld", 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 (stderr)

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