Submission #573756

# Submission time Handle Problem Language Result Execution time Memory
573756 2022-06-07T07:18:08 Z pokmui9909 Coins (BOI06_coins) C++17
100 / 100
103 ms 13916 KB
#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 time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 94 ms 13772 KB Output is correct
8 Correct 103 ms 13772 KB Output is correct
9 Correct 82 ms 13916 KB Output is correct
10 Correct 87 ms 13756 KB Output is correct