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;
}


posted on 2014-08-06 23:46  wangzhili  阅读(142)  评论(0编辑  收藏  举报