原题链接 来自蓝桥云课https://www.lanqiao.cn/problems/179/learning/
#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
set<int> st;
set<int>::iterator p;
pair<int, int> v[100100];
int work()
{
int i, j, t;
int n, d, k;
scanf("%d%d%d", &n, &d, &k);
for (i = 0; i < n; i++) scanf("%d%d", &v[i].first, &v[i].second);
sort(v, v+n);
int l = 0, r = 0;
while (r < n)
{
while (v[r].first - v[l].first < d && r < n)
{
mp[v[r].second]++;
if (mp[v[r].second] >= k)
{
st.insert(v[r].second);
}
r++;
}
while (v[r].first - v[l].first >= d)
{
mp[v[l].second]--;
l++;
}
}
for (p = st.begin(); p != st.end(); p++)
printf ("%d\n", *p);
return 0;
}
int main()
{
int T = 1;
//scanf("%d", &T);
while (T--) work();
return 0;
}