# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
226592 | MKopchev | Coins (BOI06_coins) | C++14 | 136 ms | 10100 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |