Submission #532305

#TimeUsernameProblemLanguageResultExecution timeMemory
532305rainboy도넛 (JOI14_ho_t3)C11
100 / 100
35 ms2020 KiB
#include <stdio.h> #define N 100000 long long min(long long a, long long b) { return a < b ? a : b; } long long max(long long a, long long b) { return a > b ? a : b; } long long aa[N + 1]; long long solve2(int l, int r) { int lower = l, upper = r; while (upper - lower > 1) { int j = (lower + upper) / 2; if (aa[j] - aa[l] < aa[r] - aa[j]) lower = j; else upper = j; } return l == r ? 0 : max(aa[lower] - aa[l], aa[r] - aa[upper]); } int main() { int n, i, l, r; long long ans; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%lld", &aa[i]); aa[i] += aa[i - 1]; } ans = 0; for (l = 0, r = 0; l < n; l++) { while (r < n && solve2(l, r) < aa[n] + aa[l] - aa[r]) r++; ans = max(ans, solve2(l, r - 1)); if (r < n) ans = max(ans, aa[n] + aa[l] - aa[r]); } printf("%lld\n", ans); return 0; }

Compilation message (stderr)

2014_ho_t3.c: In function 'main':
2014_ho_t3.c:28:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
2014_ho_t3.c:30:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |   scanf("%lld", &aa[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...