package hello;
import java.math.BigInteger;
import java.util.*;
public class Main{
public static void main(String[] args) {
int n,d,k;
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
d=sc.nextInt();
k=sc.nextInt();
ClickHot arr[]=new ClickHot[n];
for (int i=0;i<n;i++)
{
int time=sc.nextInt();
int id=sc.nextInt();
arr[i]=new ClickHot(time,id);
}
Arrays.sort(arr);
// System.out.println(Arrays.toString(arr));
int parentId=arr[0].id;
boolean flag=false;
for (int i=0;i<n;i++)
{
if (i+k-1<n&&arr[i+k-1].id==parentId&&arr[i+k-1].ts<d+arr[i].ts&&!flag)
{
System.out.println(parentId);
flag=true;
}
else if (arr[i].id!=parentId)
{
parentId=arr[i].id;
flag=false;
i=i-1;
}
}
}
static class ClickHot implements Comparable<ClickHot>
{
int ts;
int id;
public ClickHot(int ts, int id) {
super();
this.ts = ts;
this.id = id;
}
@Override
public int compareTo(ClickHot o) {
// TODO Auto-generated method stub
if (id==o.id)
{
return ts-o.ts;
}
else
{
return id-o.id;
}
}
@Override
public String toString() {
return "ClickHot [ts=" + ts + ", id=" + id + "]";
}
}
}
P8661 [蓝桥杯 2018 省 B] 日志统计
最新推荐文章于 2024-04-06 23:29:49 发布