Submission #226592

#TimeUsernameProblemLanguageResultExecution timeMemory
226592MKopchevCoins (BOI06_coins)C++14
100 / 100
136 ms10100 KiB
#include<bits/stdc++.h> using namespace std; const int nmax=5e5+42; int n,k; int cost[nmax],type[nmax]; int main() { scanf("%i%i",&n,&k); for(int i=1;i<=n;i++) scanf("%i%i",&cost[i],&type[i]); cost[n+1]=k; int ret=0,sum=0; for(int i=1;i<=n;i++) { if(type[i])continue; if(sum+cost[i]<cost[i+1]&&sum+cost[i]<k) { sum=sum+cost[i]; ret++; } } if(ret==0)sum=1; printf("%i\n%i\n",ret,k-sum); return 0; }

Compilation message (stderr)

coins.cpp: In function 'int main()':
coins.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i%i",&n,&k);
     ~~~~~^~~~~~~~~~~~~~
coins.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i%i",&cost[i],&type[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...