7 10 2
0 1
0 10
10 10
10 1
9 1
100 3
100 3
1
3
代码实现
#include<iostream> #include<algorithm> using namespace std; #define x first #define y second const int N = 1e5 + 10; typedef pair<int,int> PII; PII q[N]; int cnt[N]; bool st[N]; int n,d,k; int main(){ cin >> n >> d >> k; for(int i = 0;i < n;i++) cin >> q[i].x >> q[i].y; sort(q,q+n); for(int i = 0,j = 0;i < n;i++){ cnt[q[i].y] ++; while(q[i].x - q[j].x >= d){ cnt[q[j].y] --; j ++; } if(cnt[q[i].y] >= k) st[q[i].y] = true; } for(int i = 0;i <= 100000;i++) if(st[i]) cout << i << endl; return 0; }
原文:https://www.cnblogs.com/luyuan-chen/p/12257974.html