AcWing 1238. 日志统计
原题链接
中等
作者:
Value
,
2020-07-15 16:37:21
,
所有人可见
,
阅读 637
#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;
const int N = 1E5 + 10;
pii record[N];
int cnt[N];
bool st[N];
int main(){
int n, d, k; cin >> n >> d >> k;
for(int i = 0; i < n; i ++ ) cin >> record[i].first >> record[i].second;
sort(record, record + n);
int i, j; i = j = 0;
while(j < n && i <= j){
cnt[record[j].second] ++ ;
while(record[j].first - record[i].first >= d){
cnt[record[i].second] -- ;
i ++ ;
}
if(cnt[record[j].second] >= k) st[record[j].second] = true;
j ++ ;
}
for(int i = 0; i < N; i ++ ){
if(st[i]) cout << i << endl;
}
return 0;
}