AcWing 1238. 日志统计
原题链接
中等
作者:
suchong
,
2024-04-05 16:27:48
,
所有人可见
,
阅读 1
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#define x first
#define y second
using namespace std;
const int N = 100010;
typedef pair<int, int> PII;
int n, d, k;
int cnt[N];
PII logs[N];
bool st[N];
int main()
{
scanf("%d%d%d", &n, &d, &k);
for(int i=0; i<n; i++) scanf("%d%d", &logs[i].x, &logs[i].y);
sort(logs, logs+n);
for(int i=0,j=0; i<n; i++) // i在前 j在后
{
int id = logs[i].y;
cnt[id]++;
while(logs[i].x - logs[j].x >= d)
{
cnt[logs[j].y]--;
j++;
}
if(cnt[id]>=k) st[id]=true;
}
for(int i=0; i<=100000; i++)
if(st[i]) printf("%d\n",i);
return 0;
}