为啥check1函数和check2函数输出的结果不一样啊????
// Problem: T307730 雪中的入祭诗
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/T307730
// Memory Limit: 125 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 2e5 + 10;
ll a[N];
ll n, k;
void check1(ll x)
{
ll cnt = 0;
for (ll i = 1; i < n; i++)
{
ll l = 0, r = i - 1;
while (l < r)
{
ll mid = l + r + 1 >> 1;
if (a[i] - a[mid] <= x) l = mid;
else r = mid - 1;
}
if (a[i] - a[l] <= x) cnt += l;
cout << cnt << '\n';
}
cout << '\n';
}
void check2(ll x)
{
ll cnt = 0;
for (ll i = 0; i < n; i++)
{
for (int j = 0; j < i; j++)
if (a[i] - a[j] <= x) cnt++;
cout << cnt << '\n';
}
cout << '\n';
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> k;
for (ll i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
check1(1);
// check2(1);
return 0;
}