Submission #544441

#TimeUsernameProblemLanguageResultExecution timeMemory
544441rainboyCoins (BOI06_coins)C11
100 / 100
105 ms9888 KiB
#include <stdio.h> #define N 500000 int main() { static int cc[N], dd[N]; int n, k, i, cnt, x; scanf("%d%d", &n, &k); for (i = 0; i < n; i++) scanf("%d%d", &cc[i], &dd[i]); cnt = 0, x = 0; for (i = 0; i < n; i++) if (!dd[i] && x + cc[i] < (i + 1 == n ? k : cc[i + 1])) cnt++, x += cc[i]; printf("%d\n", cnt); printf("%d\n", k - (cnt == 0 ? 1 : x)); return 0; }

Compilation message (stderr)

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