An industrial actuator ships with a single-use firing latch: the very first activation request it receives causes it to fire and report a computed value, but every activation after that finds the latch already spent and reports nothing new. Each activation request carries a list of integer sensor readings. Simulate the actuator across every request it receives, in the order the requests arrive, and report what it outputs for each one.
Line 1: an integer q — the number of activation requests. Each of the next q lines describes one request: an integer k followed by k space-separated integers r_1..r_k, the sensor readings carried by that request. If k is 0, the line contains only the value 0 (an empty reading list).
Print q lines. For the first request (earliest in input order), print the sum of its sensor readings. For every request after the first, print the single word LATCHED (uppercase, no quotes) — the actuator has already fired and ignores that request's readings entirely, regardless of what they are.
Example 1
Input
3 3 1 2 3 2 5 5 0
Expected
6 LATCHED LATCHED
Explanation
The first request fires the latch, reporting the sum 1+2+3=6. The second and third requests arrive after the latch is already spent, so regardless of their readings the actuator reports LATCHED for both.
Example 2
Input
1 0
Expected
0
Explanation
There is only one request, and it is the first (and only) one, so the latch fires and reports the sum of an empty reading list, which is 0. There is no second request to report LATCHED.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →