Submission #573756

#TimeUsernameProblemLanguageResultExecution timeMemory
573756pokmui9909Coins (BOI06_coins)C++17
100 / 100
103 ms13916 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; ll N, K; ll C[500005], D[500005]; int main(){ cin.tie(0) -> sync_with_stdio(false); cin >> N >> K; for(ll i = 1; i <= N; i++){ cin >> C[i] >> D[i]; } C[N + 1] = 1e18; ll S = 0, P = 0; for(ll i = 1; i <= N; i++){ if(D[i] == 0 && S + C[i] < K && S + C[i] < C[i + 1]){ S += C[i], P++; } } if(S == 0) S = 1; cout << P << '\n' << K - S; }
#Verdict Execution timeMemoryGrader output
Fetching results...