Submission #705534

#TimeUsernameProblemLanguageResultExecution timeMemory
705534rainboyArt Exhibition (JOI18_art)C11
100 / 100
316 ms20820 KiB
#include <stdio.h> #define N 500000 #define INF 0x3f3f3f3f3f3f3f3fLL long long max(long long a, long long b) { return a > b ? a : b; } unsigned int X = 12345; int rand_() { return (X *= 3) >> 1; } long long aa[N]; int bb[N]; void sort(int *ii, int l, int r) { while (l < r) { int i = l, j = l, k = r, i_ = ii[l + rand_() % (r - l)], tmp; while (j < k) if (aa[ii[j]] == aa[i_]) j++; else if (aa[ii[j]] < aa[i_]) { tmp = ii[i], ii[i] = ii[j], ii[j] = tmp; i++, j++; } else { k--; tmp = ii[j], ii[j] = ii[k], ii[k] = tmp; } sort(ii, l, i); l = k; } } int main() { static int ii[N]; int n, h, i; long long ans, x; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%lld%d", &aa[i], &bb[i]); for (i = 0; i < n; i++) ii[i] = i; sort(ii, 0, n); x = -INF, ans = 0; for (h = 0; h < n; h++) { i = ii[h]; x = max(x, aa[i]) + bb[i]; ans = max(ans, x - aa[i]); } printf("%lld\n", ans); return 0; }

Compilation message (stderr)

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