Home Article Practice 1

1

2024-11-20 07:51  views:16  source:mmyyyy    

const int N = 2e5 + 10;
int n, d, k;
typedef pair<int, int> PII;
#define x first
#define y second
PII a[N];
int cnt[N];
bool b[N];
int main()
{
cin >> n >> d >> k;
for (int i = 1; i <= n; i ++ ){
int ts, id;
cin >> ts >> id;
a[i].x = ts;
a[i].y = id;
}
sort(a + 1, a + n + 1);
for (int i = 1, j = 1; i <= n; i ++ ){//i在前面,j在后面
int t = a[i].y;
cnt[t]++;
while(a[i].x - a[j].x >= d){
cnt[a[j].y]--;
j++:
}
if(cnt[t] >= k){
b[t] = true;
}
}
for (int i = 1; i <= 100000; i ++ ){
if(b[i]){
cout << i << '\n';
}
}
return 0;
}



Disclaimer: The above articles are added by users themselves and are only for typing and communication purposes. They do not represent the views of this website, and this website does not assume any legal responsibility. This statement is hereby made! If there is any infringement of your rights, please contact us promptly to delete it.

字符:    改为:
去打字就可以设置个性皮肤啦!(O ^ ~ ^ O)