QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22397. 計時卡

Statistics

Farmer John 想提高農場生產力,因此乳牛在擠奶機旁待得更久就能多得乾草。為實施計畫,他讓 $N$ 頭乳牛($1 \le N \le 145$)使用計時卡,編號為 $1\ldots N$。開始使用擠奶機時,乳牛在總計時卡上記下開始時間;離開時也記下離開時間。FJ 很幸運,有足夠的擠奶機同時給所有乳牛擠奶。

時間紀錄輸入一個電腦檔案,每行包含乳牛編號 $C$($1 \le C \le N$)、關鍵字('START' 或 'STOP'),以及兩個空格分隔的整數 $HH$ 和 $MM$($0 \le HH \le 23$;$0 \le MM \le 59$)表示的時間。乳牛從不會在擠奶機旁待過午夜。檔案完整:每頭乳牛的每筆 START 紀錄在輸入檔案後面都有對應的 STOP 紀錄。

計算每頭乳牛在擠奶機旁待的總時間。

例如,考慮只有兩頭乳牛的計時檔案。檔案不僅包含乳牛數,還包含時間紀錄總數 $Nlines$($1 \le Nlines \le 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

乳牛 1 在 9:00-10:00 和 17:00-17:42 使用擠奶機,共 1 小時 42 分鐘(1:42)。乳牛 2 在 9:30-10:15 使用擠奶機,共 45 分鐘。

輸入格式

  • 第 1 行:兩個空格分隔的整數 $N$ 和 $Nlines$。
  • 第 $2\ldots Nlines+1$ 行:每行包含四個空格分隔的項:$C$、關鍵字、$HH$、$MM$。

輸出格式

  • 第 $1\ldots N$ 行:第 $i$ 行包含兩個空格分隔的整數,分別為乳牛 $i$ 在擠奶機旁待的小時數和分鐘數。分鐘數當然不會超過 59。

範例

輸入格式 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

1 42
0 45

題目作者:Rob Kolstad,2009

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.