Submission #395513

# Submission time Handle Problem Language Result Execution time Memory
395513 2021-04-28T12:35:04 Z PanTkd Coins (BOI06_coins) C++14
0 / 100
1000 ms 332 KB
//
//  main.cpp
//
//  Created by Panagiotis Chadjicostas on
//  Copyright © Panagiotis Hadjicostas. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iterator>
#include <limits>
#include <list>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
#define fo(i,a,b) for(int i = a; i<=b; i++)
#define f(i,b) for(int i=0;i<b;i++)
#define F first
#define S second
#define sz size
const ll MOD=ll(1e9)+7;
const ll MAXN=2*ll(1e6);
void checker(){
    ll n=rand()%20+2;
    vi a(n,ll());
    for(ll i=0;i<n;i++){
        a[i]=rand()%20+2;
    }
    for(ll b=0;b<(1<<n);b++){
        vi on,off;
        for(ll i=0;i<n;i++){
            if(i&(1<<i)){
                on.push_back(i);
            }
            else{
                off.push_back(i);
            }
        }
    }
}
///////////////////////////////////////////////////////////////////////

struct coin {
    ll v;bool f;
};
void solve(){
    ll n,k;cin>>n>>k;

    coin c[n+2];
    for(ll i=1;i<=n;i++){
        cin>>c[i].v>>c[i].f;
    }
    c[n+1].v=k;c[n+1].f=1;
    ll ans=0,cnt=0;
    for(ll i=1;i<=n;i++){
        if(c[i].f==0 && ans+c[i].v<c[i+1].v){
            ans+=c[i].v;
            cnt++;
        }
    }

    cout<<cnt<< endl << min(k-ans,k-1)<<endl;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;cin>>t;
    while (t--) {
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 204 KB Time limit exceeded
2 Incorrect 27 ms 204 KB Output isn't correct
3 Execution timed out 1082 ms 204 KB Time limit exceeded
4 Execution timed out 1079 ms 204 KB Time limit exceeded
5 Execution timed out 1096 ms 204 KB Time limit exceeded
6 Execution timed out 1096 ms 332 KB Time limit exceeded
7 Execution timed out 1089 ms 332 KB Time limit exceeded
8 Execution timed out 1087 ms 332 KB Time limit exceeded
9 Execution timed out 1089 ms 332 KB Time limit exceeded
10 Execution timed out 1095 ms 332 KB Time limit exceeded