#include<bits/stdc++.h>
#define ll long long
#define ss second
#define ff first
#define pb push_back
#define endl "\n"
using namespace std;
ll n,k,t,a,mx,mx1;
vector<ll> vv;
map<ll,ll> mp;
int main(){
ios::sync_with_stdio(false);
cout.tie(0);
cin.tie(0);
cin>>n>>k;
for(ll i=1;i<=n;i++){
cin>>a>>t;
mp[a]=t;
vv.pb(a);
}
sort(vv.begin(),vv.end());mx1=1;
for(ll i=1;i<k;i++){
ll l=k-i,sum=0,o;
// cout<<i<<'p';
while(l!=0){
auto it=lower_bound(vv.begin(),vv.end(),l);
if(it==vv.begin()) break;
it--;
o=*it;
// cout<<o<<' ';
if(mp[o]==0) sum++;
l=l%o;
}
// cout<<' '<<sum<<endl;
if(mx<sum){mx1=i+1;mx=sum;}
}
cout<<mx<<' '<<mx1;
}
/*7 25
1 0
2 0
3 1
5 0
10 0
13 0
20 0*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |