n,d,k=map(int,input().split())
r=dict()
for i in range(n):
ts,id=map(int,input().split())
if id not in r.keys():
r[id]=[ts]
else:
r[id].append(ts)
s=[]#记录符合的id
for i in r.keys():
l=r[i]
l.sort()
if len(l)<k:
continue
for j in range(len(l)):
if j+k-1<=len(l)-1:
if l[j+k-1]-l[j]<=d-1:
s.append(i)
break
s.sort()
for i in s:
print(i)
n,d,k=map(int,input().split())
r=dict()
for i in range(n):
ts,id=map(int,input().split())
if id not in r.keys():
r[id]=[ts]
else:
r[id].append(ts)
s=[]#记录符合的id
for i in r.keys():
l=r[i]
l.sort()
st=0
if len(l)<k:
continue
while st+k-1<=len(l)-1:
if l[st+k-1]-l[st]<=d-1:
st+=1
s.append(i)
break
s.sort()
for i in s:
print(i)
两段代码,完全一样,只不过for循环A了,while超时了,为啥啊,差别有这么大吗