题目:日志统计(AcWing)

解析:本题的尺子长度为时间
#include<bits/stdc++.h>
using namespace std;
namespace{
template<typename t="">
inline void read(T &s){
T f=1;s=0;char ch=getchar();
for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-1;
for(;isdigit(ch);ch=getchar()) s=(s<<1)+(s<<3)+(ch^48);
s*=f;
}
}
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
int const N=1e5+7;
struct L{
int ts,id;
friend bool operator<(L a,L b){
return a.ts < b.ts ;
}
}a[N];
int n,d,k;
map<int,int>mp;
set<int>s;
int main(){
read(n);read(d);read(k);
for(int i=1;i<=n;++i) {
read(a[i].ts);read(a[i].id);
}
sort(a+1,a+n+1);
for(int i=0,j=1;j<=n&&i<=n;){
while(a[j].ts - a[i].ts +1 <= d && j<=n){
mp[a[j].id]++;
if(mp[a[j].id]>=k) s.insert(a[j].id);
j++;
}
while(a[j].ts - a[i].ts +1 > d && j<=n && i<=n){
mp[a[i].id]--;
i++;
}
}
for(set<int>::iterator p=s.begin();p!=s.end();p++){
cout << *p << endl;
}
return 0;
}</int></int></typename>