#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 time | Memory | Grader output |
|---|
| Fetching results... |