Submission #213218

#TimeUsernameProblemLanguageResultExecution timeMemory
213218dolphingarlicCoins (BOI06_coins)C++14
100 / 100
138 ms10104 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...