输入:
7 10 2
0 1
0 10
10 10
10 1
9 1
100 3
100 3
输出:
1
3
import java.util.Arrays;
import java.util.Scanner;
// 1:无需package
// 2: 类名必须Main, 不可修改
public class Main {
static int cnt = 0;;
static boolean[]vis = new boolean[100010];
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int N = scan.nextInt();
int D = scan.nextInt();
int K = scan.nextInt();
blog[]arr = new blog[N];
int[]ids = new int[100010];
for (int i = 0; i < N; i++) {
int ts = scan.nextInt();
int id = scan.nextInt();
arr[i] = new blog(ts, id);
}
Arrays.sort(arr);
for (int i = 0,j=0; i < arr.length; i++) {
int id = arr[i].id;
ids[id]++;
while (arr[i].ts-arr[j].ts>=D) {
ids[arr[j].id]--;
j++;
}
if (ids[id]>=K) {
vis[id] = true;
}
}
for (int i = 0; i < vis.length; i++) {
if (vis[i]) {
System.out.println(i);
}
}
scan.close();
}
}
class blog implements Comparable<blog>{
int ts;
int id;
public blog(int ts, int id) {
this.ts = ts;
this.id = id;
}
@Override
public int compareTo(blog o) {
// TODO Auto-generated method stub
return this.ts-o.ts;
}
}