Submission #137598

#TimeUsernameProblemLanguageResultExecution timeMemory
137598khsoo01Coins (BOI06_coins)C++11
100 / 100
120 ms4256 KiB
#include<bits/stdc++.h> using namespace std; const int N = 500005; int n, m, a[N], b[N], ans1, ans2; int main() { scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) { scanf("%d%d",&a[i],&b[i]); } a[n+1] = m; for(int i=1;i<=n;i++) { if(b[i]) continue; if(ans2 + a[i] < a[i+1]) { ans1++; ans2 += a[i]; } } printf("%d\n%d\n", ans1, m-max(1, ans2)); }

Compilation message (stderr)

coins.cpp: In function 'int main()':
coins.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~
coins.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&a[i],&b[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...