听灌多
  • 板块灌水区
  • 楼主Xu7300
  • 当前回复11
  • 已保存回复11
  • 发布时间2024/7/16 19:39
  • 上次更新2024/7/16 20:38:29
查看原帖
听灌多
972195
Xu7300楼主2024/7/16 19:39

有大佬解释为什么会这样吗?(我是蒟蒻) 题目名称:DEGwer's Doctoral Dissertation code:

#include<bits/stdc++.h>
using namespace std;
int n,k,t,a[200005],cnt,p;
int main(){	
	cin>>n>>k>>t;
	for(int i=1;i<=k;i++)cin>>a[i];
	sort(a+1,a+k+1);
	p=a[1];
	for(int i=2;i<=k;i++){
		if(a[i]-p<t)cnt++;
		else p=a[i];
	}
	cout<<cnt;
	return 0;
}
2024/7/16 19:39
加载中...