比赛 EYOI与SBOI开学欢乐赛1st 评测结果 AAAATTTTTT
题目名称 双倍腹肌量 最终得分 40
用户昵称 HeSn 运行时间 6.000 s
代码语言 C++ 内存使用 4.36 MiB
提交时间 2022-08-29 19:59:02
显示代码纯文本
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m;
//int x[200000],t[200000];
struct node{
	int x,t;
}d[200000];
bool cmp(node y,node z)
{
	return y.t<z.t;
}
int ans=0x3f3f3f3f;
int main(){
	freopen("double_muscle.in","r",stdin);
	freopen("double_muscle.out","w",stdout);
cin>>n>>m;
for(int q=1;q<=n;q++) cin>>d[q].x>>d[q].t;
sort(d+1,d+n+1,cmp);
for(int q=1;q<=n;q++)
{
	for(int w=q+1;w<=n;w++)
	{
		if(d[w].t-d[q].t>=m) ans=min(ans,abs(d[q].x-d[w].x));
	}
}
cout<<ans;
return 0;
}