F5OA #1
Top 3 Trending Hashtags in a Time Window
估计简单可在线判题
Count how many times each hashtag appears in the tweets within a closed time window, and return the top three, sorted by count in descending order and then by tag in ascending lexicographic order.
This site's standard input/output format and supplementary bounds are as described in this problem.
输入格式
The first line contains n currentTime timeWindow (n≤2×10^5, total text length ≤10^6, timestamps and the time window are non-negative and ≤10^9). Each of the next n lines contains a timestamp, a tab character, and a tweet; a tag starts with # followed by ASCII letters/digits/underscores.
输出格式
Output one hashtag per line, keeping the leading #; output nothing if there are no tags.
样例 1
输入:
4 4 2
1 hi #a #b
2 #a !!!
3 no tag
4 #b #b
输出:
#b
#a
样例 2
输入:
2 5 1
3 #z #A
5 #z #a
输出:
#a
#z
样例 3
输入:
3 21 2
17 x #a1 #a
27 x #a1 #a
12 none #_
输出: