# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
572663 | byunjaewoo | Coins (BOI06_coins) | C++17 | 90 ms | 10452 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;
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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |