Submission #1321538

#TimeUsernameProblemLanguageResultExecution timeMemory
1321538nathako9nCoins (BOI06_coins)C++20
90 / 100
57 ms4784 KiB
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define f first
#define s second
#define tii tuple<int,int>
#define time timee
using namespace std;
int n;
const int N = 500005;
ll ar[N+3],k;
bool hav[N+3];
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>ar[i]>>hav[i];
    }
    ll sum=0,cnt=0;
    ar[n+1]=k;
    for(int i=1;i<=n;i++){
        if(hav[i])continue;
        ll dif=ar[i+1]-ar[i];
        if(sum<dif){
            sum+=ar[i];
            ++cnt;
        }
    }
    cout<<cnt<<endl<<k-sum;
    return 0;
}
/*

7 25
1 0
2 0
3 1
5 0
10 0
13 0
20 0


*/
#Verdict Execution timeMemoryGrader output
Fetching results...