Submission #527876

#TimeUsernameProblemLanguageResultExecution timeMemory
527876rainboy케이크 (JOI13_cake)C11
10 / 100
1555 ms1644 KiB
#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)

cake.c: In function 'main':
cake.c:10:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
cake.c:12:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...