Submission #481397

#TimeUsernameProblemLanguageResultExecution timeMemory
481397rainboyPod starim krovovima (COCI20_psk)C11
50 / 50
1 ms204 KiB
#include <stdio.h> #define N 1000 long long min(long long a, long long b) { return a < b ? a : b; } unsigned int X = 12345; int rand_() { return (X *= 3) >> 1; } int aa[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, i, k; long long sum; scanf("%d", &n); sum = 0; for (i = 0; i < n; i++) { int a; scanf("%d%d", &a, &aa[i]); sum += a; ii[i] = i; } sort(ii, 0, n); for (i = 0; i < n; i++) { int i_ = ii[i]; aa[i_] = min(aa[i_], sum), sum -= aa[i_]; } k = 0; for (i = 0; i < n; i++) if (aa[i] == 0) k++; printf("%d\n", k); for (i = 0; i < n; i++) printf("%d ", aa[i]); printf("\n"); return 0; }

Compilation message (stderr)

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