This commit is contained in:
HuangHai
2025-08-30 18:35:01 +08:00
commit 1f397eca87
6258 changed files with 1487241 additions and 0 deletions

24
LuoGu/RuMen/P1296.cpp Normal file
View File

@@ -0,0 +1,24 @@
#include<bits/stdc++.h>
using namespace std;
//定义大数组,放在主函数外边
int a[1000001], n, f, i, j, k;
int main() {
cin >> n >> f;
for (i = 1; i <= n; ++i)
cin >> a[i];
k = 0;
//对数组进行一次排序
sort(a + 1, a + (n + 1));
//双重循环
for (i = 1; i < n; i++)
for (j = i + 1; j <= n; ++j) {
if (a[j] - a[i] > f)
break;
k++;
}
cout << k << endl;
return 0;
}