#P10899. Longest Combo in Rhythm Game
Longest Combo in Rhythm Game
Longest Combo in Rhythm Game
In this problem, you are given a log file of a rhythm game. The log contains N
records. Each record consists of three fields in order: the expected key (the key that should have been pressed), the actual key pressed by the player, and the timestamp (in milliseconds) when the key was pressed.
A combo is defined as a sequence of K consecutive correct key presses (i.e. the actual key matches the expected key) that satisfy the following condition: for every two consecutive hits in this sequence, the time difference is at most 1 s
(i.e. 1000 ms). In other words, if the timestamps of the consecutive correct hits are \(t_1, t_2, \dots, t_K\), then the combo is valid if and only if
\[
\forall i \; (1 \le i
Your task is to compute the maximum combo length K that appears in the game log. If there is no correct press or no valid combo, output the maximum combo length (which might be 0 if no record is correct).
inputFormat
The input begins with an integer N
(the number of records). Following this, there are N
lines. Each line contains two characters and an integer separated by spaces: the expected key
, the actual key
, and the timestamp
(in milliseconds). The records are given in chronological order.
outputFormat
Output a single integer representing the maximum combo length (i.e. the length of the longest valid sequence of consecutive correct key presses as defined above).
sample
5
A A 1000
B B 1800
C C 3000
D D 3950
E E 5000
2