![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLiAzNfRHLGZkRGZkRfJ3bs92YsYTMfVmepNHL3NGROFTVU9EeVpHW3BjMMBjVtJWd0ckW65UbM5WOHJWa5kHT20ESjBjUIF2X0hXZ0xCMx81dvRWYoNHLrdEZwZ1Rh5WNXp1bwNjW1ZUba9VZwlHdssmch1mclRXY39CXldWYtlWPzNXZj9mcw1ycz9WL49zZuBnLwkjM1QTOxkTMxAzMwEjMwIzLc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
代码如下:
#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<int, int>PII;
#define x first
#define y second
const int N = 100010;
bool st[N];
int n, d, k;
PII a[N];
int cnt[N];
int main() {
cin >> n >> d >> k;
for (int i = 0, j = 0; i < n; i++)
cin >> a[i].x >> a[i].y;
sort(a, a + n);
for (int i = 0, j = 0; i < n; i++) {
cnt[a[i].y]++;
while (a[i].x - a[j].x >= d) {
cnt[a[j].y]--;
j++;
}
if (cnt[a[i].y] >= k)
st[a[i].y] = true;
}
for (int i = 0; i < N; i++) {
if (st[i])
cout << i << endl;
}
return 0;
}