Submission #707725

#TimeUsernameProblemLanguageResultExecution timeMemory
707725rainboyJust Long Neckties (JOI20_ho_t1)C11
100 / 100
133 ms11576 KiB
#include <stdio.h> #define N 200000 int min(int a, int b) { return a < b ? a : b; } int max(int a, int b) { return a > b ? a : b; } unsigned int X = 12345; int rand_() { return (X *= 3) >> 1; } int *xx; 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 (xx[ii[j]] == xx[i_]) j++; else if (xx[ii[j]] < xx[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 aa[N + 1], bb[N], ii[N + 1], jj[N], pp[N + 1], qq[N + 1], ans[N + 1]; int n, i, j; scanf("%d", &n); for (i = 0; i <= n; i++) scanf("%d", &aa[i]); for (j = 0; j < n; j++) scanf("%d", &bb[j]); for (i = 0; i <= n; i++) ii[i] = i; xx = aa, sort(ii, 0, n + 1); for (j = 0; j < n; j++) jj[j] = j; xx = bb, sort(jj, 0, n); pp[0] = 0; for (i = 0; i < n; i++) pp[i + 1] = max(pp[i], aa[ii[i]] - bb[jj[i]]); qq[n] = 0; for (j = n - 1; j >= 0; j--) qq[j] = max(qq[j + 1], aa[ii[j + 1]] - bb[jj[j]]); for (i = 0; i <= n; i++) ans[ii[i]] = max(pp[i], qq[i]); for (i = 0; i <= n; i++) printf("%d ", ans[i]); printf("\n"); return 0; }

Compilation message (stderr)

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