lightoj 1016

时间:2023-03-09 02:01:29
lightoj 1016

水题,排个序直接搞。

#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN = 50010;
int y[MAXN];
int main(){
int t, x, n, w, CASE(0);
scanf("%d", &t);
while(t--){
scanf("%d%d", &n, &w);
for(int i = 0;i < n;i ++) scanf("%d%d", &x, y+i);
sort(y, y+n);
int ans(0);
for(int i = 0;i < n;i ++){
ans ++;
for(int j = i; y[i]-y[j] <= w; i ++);
i--;
}
printf("Case %d: %d\n", ++CASE, ans);
}
return 0;
}