Submission #226592

# Submission time Handle Problem Language Result Execution time Memory
226592 2020-04-24T13:04:04 Z MKopchev Coins (BOI06_coins) C++14
100 / 100
136 ms 10100 KB
#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

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 time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 124 ms 9976 KB Output is correct
8 Correct 122 ms 9976 KB Output is correct
9 Correct 136 ms 10100 KB Output is correct
10 Correct 133 ms 9848 KB Output is correct