[关闭]
@inkysakura 2017-04-26T14:31:14.000000Z 字数 322 阅读 1142

lightoj1016

CODE


#include <iostream>
#include <algorithm>
using namespace std;
int n,w;
int y[50005];
int ans=0;
int nCase,tp;
int main()
{
        int t;
        cin >> t;
        while(t--)
        {
                ans=0;
                cin >> n >> w;
                for(int i=0;i<n;i++)
                        cin >>tp>>y[i];
                sort(y,y+n);
                int cur=-10005-1e9;
                for(int i=0;i<n;i++)
                {
                        if(cur+w<y[i])
                        {
                                ans++;
                                cur=y[i];
                        }
                }
                cout << "Case "<<++nCase<<": "<<ans<<endl;
        }
        return 0;
}
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注