Submission #544441

# Submission time Handle Problem Language Result Execution time Memory
544441 2022-04-01T23:41:04 Z rainboy Coins (BOI06_coins) C
100 / 100
105 ms 9888 KB
#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

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 time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 94 ms 9864 KB Output is correct
8 Correct 99 ms 9844 KB Output is correct
9 Correct 105 ms 9888 KB Output is correct
10 Correct 100 ms 9724 KB Output is correct