AcWing 1238. 日志统计
原题链接
中等
作者:
wjie
,
2020-07-01 20:05:49
,
所有人可见
,
阅读 440
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
const int N = 1e5 + 5;
vector<int> G[N];
set<int> ID;
int n, d, k;
bool isHot(int id)
{
sort(G[id].begin(), G[id].end());
for (int i = 0; i + k - 1< G[id].size(); ++i)
{
if (G[id][i+k-1] - G[id][i] < d)
return true;
}
return false;
}
int main()
{
scanf("%d %d %d", &n, &d, &k);
for (int i = 0; i < n; ++i)
{
int ts, id;
scanf("%d %d", &ts, &id);
G[id].push_back(ts);
ID.insert(id);
}
set<int>::iterator it;
for (it = ID.begin(); it != ID.end(); ++it)
{
int id = *it;
if (isHot(id))
printf("%d\n", id);
}
return 0;
}