AcWing 1238. 日志统计--c++
原题链接
中等
作者:
凯濛
,
2024-04-07 15:05:07
,
所有人可见
,
阅读 1
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
const int N=100010;
typedef pair<int,int>PII;
int n,d,k;
PII logs[N];
int cnt[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++)
{
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<=100010;i++)
if(st[i])
printf("%d\n",i);
return 0;
}