Submission #572663

#TimeUsernameProblemLanguageResultExecution timeMemory
572663byunjaewooCoins (BOI06_coins)C++17
90 / 100
90 ms10452 KiB
#include <bits/stdc++.h> using namespace std; using ll=long long; const int Nmax=500010; int N; ll K, cnt, sum, C[Nmax]; bool D[Nmax]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>N>>K; for(int i=1; i<=N; i++) cin>>C[i]>>D[i]; C[N+1]=LLONG_MAX; for(int i=1; i<=N; i++) if(!D[i]) { if(sum+C[i]>=C[i+1] || sum+C[i]>=K) continue; sum+=C[i]; cnt++; } cout<<cnt<<"\n"<<K-sum; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...