# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
527876 | rainboy | 케이크 (JOI13_cake) | C11 | 1555 ms | 1644 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#define N 300000
int main() {
static int aa[N];
int n, i, l, r, k;
long long sum;
scanf("%d", &n);
for (i = 0; i < n; i++)
scanf("%d", &aa[i]);
for (i = 0; i < n; i++) {
l = r = i, k = 1, sum = aa[i];
while (r - l + 1 < n)
if (aa[(l - 1 + n) % n] > aa[(r + 1) % n]) {
l--;
if (k++ % 2 == 0)
sum += aa[(l + n) % n];
} else {
r++;
if (k++ % 2 == 0)
sum += aa[r % n];
}
printf("%lld\n", sum);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |