OtherOA #8
Process Messages (FrontEnd focused Full-Stack Eng :)
EasyJudge-ready
Topics (AI-labelled)In-place ArraysStacks & Heaps
Process messages by priority and then by time. This site specifies a stable sort for equal keys and adds the standard input protocol.
Input
The first line contains n (1≤n≤10^5), followed by n lines of timestamp:priority. timestamp is 0000..9999, and priority is 1..5.
Output
Sort by priority number ascending (1 is highest), then by timestamp value ascending, and output each message as is, one per line. Messages with identical keys keep their input order (stable sort).
Example 1
Input:
3
1045:2
0100:1
0100:2
Output:
0100:1
0100:2
1045:2
Example 2
Input:
3
0000:5
9999:1
0001:1
Output:
0001:1
9999:1
0000:5
Example 3
Input:
3
1200:3
1200:3
0000:3
Output:
0000:3
1200:3
1200:3
Editorial
Loading solution…