← 返回 scale.ai 的题目列表Party Times / Peak Concurrent Parties (Time Range Overlap Counting)
类型:online_judge
Problem: Party Times (Count concurrent parties by hour)
Given multiple parties with start and end timestamps, compute:
For each integer hour (0–23), how many parties are ongoing at that hour.
The hour with the maximum number of ongoing parties and that maximum count.
Input
Line 1: integer n, the number of parties.
Next n lines: two timestamps start end for one party.
Timestamp format: HH:MM:SS (24-hour).
Rules
Each party is active on interval [start, end):
inclusive of start
exclusive of end
The counting timepoints are exact hours h:00:00. For each h in 0..23, count parties satisfying start <= h:00:00 < end.
Output
Line 1: integer best_hour (0–23). If tie, output the smallest hour.
Line 2: integer best_count.
Line 3: a length-24 dictionary/map from hour integer 0..23 to the corresponding count.
Constraints
1 <= n <= 2*10^5
Example
Input:
3
09:00:00 11:00:00
10:30:00 12:00:00
23:00:00 23:59:59
Output (one valid formatting):
10
2
{0:0,1:0,...,9:1,10:2,11:1,...,23:1}
Example
Input
3
09:00:00 11:00:00
10:30:00 12:00:00
23:00:00 23:59:59
Output
10
2
{0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:1,10:2,11:1,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:1}