#P8661. [蓝桥杯 2018 省 B] 日志统计

[蓝桥杯 2018 省 B] 日志统计

Description

Xiaoming maintains a programmer forum. Now he has collected a set of "like" logs with a total of NN lines. Each line is in the format ts id, meaning that at time tsts, the post with number idid received one "like".

Now Xiaoming wants to count which posts have ever been "hot posts". If a post has received at least KK likes within any time period of length DD, Xiaoming considers that this post has once been a "hot post".

More specifically, if there exists a time TT such that the post receives at least KK likes during the time interval [T,T+D)[T, T + D) (note that it is a left-closed right-open interval), then this post has once been a "hot post".

Given the logs, please help Xiaoming list the IDs of all posts that have ever been "hot posts".

Input Format

The first line contains three integers NN, DD, and KK.

The following NN lines each contain one log entry, with two integers tsts and idid.

Output Format

Output the IDs of hot posts in increasing order. Print one idid per line.

7 10 2  
0 1  
0 10    
10 10  
10 1  
9 1
100 3  
100 3  
1  
3  

Hint

For 50%50\% of the testdata, 1KN10001 \le K \le N \le 1000.

For 100%100\% of the testdata, 1KN1051 \le K \le N \le 10^5, and 0id,ts1050 \le id, ts \le 10^5.

Time limit: 1 second, 256 MB. Lanqiao Cup 2018, 9th Provincial Contest.

Translated by ChatGPT 5