Submission #395513

#TimeUsernameProblemLanguageResultExecution timeMemory
395513PanTkdCoins (BOI06_coins)C++14
0 / 100
1096 ms332 KiB
// // 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 timeMemoryGrader output
Fetching results...