Time Cards
Time limit1sMemory limit128 MB
For each cow, pair her START and STOP entries and print the total time she spent at the milking machine as hours and minutes.
- Level
Easy2 of 10
- Topics
- Implementation, Simulation, Array
- Solved
- No attempts yet
Problem
To improve productivity, a farmer gives each cow extra hay based on how long it spends at a milking machine, so every cow now uses a time card. When a cow starts at a machine she writes the start time on the master card, and when she leaves she writes the stop time. There are enough machines that every cow can be milked at the same time.
There are cows numbered () and total entries (). Each entry lists a cow number (), a keyword (START or STOP), and a time given as two integers and (, ). Cows never stay at a machine past midnight, and every START entry has a matching STOP entry that appears later in the file.
Compute the total time each cow spends at the milking machine.
Input
- Line 1: two space-separated integers and .
- Lines : each line has four space-separated values — , the keyword (
STARTorSTOP), , and .
Output
- Lines : line contains two space-separated integers — the number of hours and the number of minutes that cow spent at the milking machine. The minutes value never exceeds 59.