Submission #213218

# Submission time Handle Problem Language Result Execution time Memory
213218 2020-03-25T09:59:12 Z dolphingarlic Coins (BOI06_coins) C++14
100 / 100
138 ms 10104 KB
#include <cstdio>

int a[500001], b[500001];

int main() {
	int n, k, sm = 0, cnt = 0;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) scanf("%d %d", a + i, b + i);
	a[n] = k;
	for (int i = 0; i < n; i++) {
		if (b[i]) continue;
		if (sm + a[i] < a[i + 1]) sm += a[i], cnt++;
	}
	printf("%d\n%d\n", cnt, k - (sm ? sm : 1));
	return 0;
}

Compilation message

coins.cpp: In function 'int main()':
coins.cpp:7:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &k);
  ~~~~~^~~~~~~~~~~~~~~~~
coins.cpp:8:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 0; i < n; i++) scanf("%d %d", a + i, b + i);
                              ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 128 ms 10104 KB Output is correct
8 Correct 124 ms 10032 KB Output is correct
9 Correct 138 ms 9976 KB Output is correct
10 Correct 126 ms 9720 KB Output is correct