#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
int main()
{
ll i,j,k,l,m,n,test,y[100009],x,w;
cin>>test;
for(k=1;k<=test;k++)
{
cin>>n>>w;
for(i=0;i<n;i++)
{
cin>>x>>y[i];
}
sort(y,y+n);
ll ans=1;
ll spc=y[0]+w;
for(i=1;i<n;i++)
{
if(y[i]>spc)
{
ans++;
spc=y[i]+w;
}
}
cout<<"Case "<<k<<": "<<ans<<endl;
}
return 0;
}
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
int main()
{
ll i,j,k,l,m,n,test,y[100009],x,w;
cin>>test;
for(k=1;k<=test;k++)
{
cin>>n>>w;
for(i=0;i<n;i++)
{
cin>>x>>y[i];
}
sort(y,y+n);
ll ans=1;
ll spc=y[0]+w;
for(i=1;i<n;i++)
{
if(y[i]>spc)
{
ans++;
spc=y[i]+w;
}
}
cout<<"Case "<<k<<": "<<ans<<endl;
}
return 0;
}
No comments:
Post a Comment