➤ Problem Link : 1217B. Zmei Gorynich
✅ C++ Solution :
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
int t;
cin>>t;
while(t--)
{
ll n,x,p,q;
cin>>n>>x;
ll mxi=-1;
ll d=INT_MIN;
for(int i=0;i<n;i++)
{
cin>>p>>q;
mxi=max(mxi,p);
d=max(d,p-q);
}
if(mxi>=x)
{
cout<<"1\n";
continue;
}
if(d<=0)
cout<<"-1\n";
else
{
ll ans=(ceil)((double)(x-mxi)/d);
ans++;
cout<<ans<<"\n";
}
}
}
Thank you for your patience reading. If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Whatsapp or Facebook.
😇Happy Learning!!
