1612--【USACO】Time Cards(时间卡片)

1612: 【USACO】Time Cards(时间卡片)


时间限制: 1.000 Sec  内存限制: 64 MB
提交: 39  解决: 28
[提交] [状态] [报告] [命题人:]

题目描述

Farmer John wanted to improve farm productivity, so his cows now get extra hay if they spend more time at a milking machine. To implement this plan, he has instituted the use of time cards for each of the N (1 <= N <= 145) cows conveniently numbered 1..N. When a cow starts at a milking machine, she enters the start time on the master time card. Likewise, when she leaves, she notes that on the master time card, as well. FJ is fortunate to have enough milking machines that he can milk every cow at the same time.
The time entries are typed into a computer file where each line includes a cow number C (1 <= C <= N), a keyword ('START' or 'STOP'),and the time expressed as two space-separated integers HH and MM (0 <= HH <= 23; 0 <= MM <= 59). Cows never stay at the machine past midnight. The timecard file is complete in the sense that every cow's START entry contains a corresponding STOP entry later in the input file. Calculate the total time each cow spends at the milking machine. By way of example, consider a time card file for just two cows. The file includes not only the number of cows but also the total number of time card entries, Nlines (1 <= Nlines <= 1,458).
2 6
1 START 9 0
2 START 9 30
1 STOP 10 0
2 STOP 10 15
1 START 17 0
1 STOP 17 42
Cow 1 spent times 9:00-10:00 and 17:00-17:42 at the machine for a total of one hour and 42 minutes (1:42). Cow 2 spent time 9:30-10:15 at the machine, for a total of 45 minutes.

农场主约翰想要提高他农场的生产效率,所以他的奶牛们获得了更多的干草,前提是它们花费更多的时间在挤奶机器上挤奶。为了方便实施这个机器计划,他为N(1 <= N <= 145)头奶牛(编号为1..N)设立了时间卡片,当一头奶牛开始在机器上挤奶,机器会在时间卡片上记录它的开始时间,同样的,当它离开时,机器会记录它的结束时间,FJ很幸运,他有足够的挤奶机器可以让奶牛们在同一时间开始挤奶。
每一个时间条目会包括一个奶牛的编号C (1 <= C <= N),一个关键字 ('START' or 'STOP'),和两个用空格分开的整数HH、MM (0 <= HH <= 23; 0 <= MM <= 59)来表示时间, Cows never stay at the machine past midnight.(不会翻译)时间卡片文件一定是完整的,如果某头牛有一条开始的时间条目则一定有一条这头牛之后的结束时间条目。试计算每头牛花费在挤奶机器上总的时间。例如,有2头牛,记录的总的时间条目有Nlines (1 <= Nlines <= 1,458)条【PS..不可能是1,一定是偶数】
2 6 
1 START 9 0 
2 START 9 30 
1 STOP 10 0 
2 STOP 10 15 
1 START 17 0 
1 STOP 17 42 
奶牛1有两个时间段在挤奶,9:00-10:00 和 17:00-17:42,总的挤奶时间是1小时42分钟(1:42),奶牛2在9:30-10:15挤奶,总的挤奶时间是45分钟。

输入

* Line 1: Two space-separated integers: N and Nlines
* Lines 2..Nlines+1: Each line contains four space-separated entities: C, keyword, HH, and MM

第1行:2个空格隔开的整数:N和Nlines
第2..Nlines+1行:每一行包含4个空格隔开的一个时间条目:C, keyword, HH, and MM

输出

* Lines 1..N: Line i contains two space-separated integers that are respectively the number of hours and minutes that cow i spends at the milking machine. Of course, the minutes value never exceeds 59.

第1..N行:第i行2个空格隔开的整数,分别表示奶牛i挤奶的总的小时数和分钟数。当然,分钟数不会超过59。

样例

输入  复制
2 6 1 START 9 0 2 START 9 30 1 STOP 10 0 2 STOP 10 15 1 START 17 0 1 STOP 17 42
输出  复制
1 42 0 45

来源/分类