時間限制 2000 ms ・ 記憶體限制 256 MB
題目描述
教授每天只能在 10:00 到 18:00 之間午睡。給定當天行程,找出最長的一段連續空閒時間;若有多段同長,選開始時間最早者。
輸入格式
每組代表一天,先給行程數 s(1 ≤ s ≤ 100),接著 s 行格式為「開始時間 結束時間 行程說明」。時間為 hh:mm,介於 10:00 與 18:00,開始早於結束。每行最多 255 個字元,行程不保證按時間排序。讀到 EOF;保證每天有空閒時間。
輸出格式
輸出 Day #d: the longest nap starts at hh:mm and will last for ...。不足 60 分鐘時填 M minutes.;至少 60 分鐘時填 H hours and M minutes.。即使數字為 1 也不改成單數。天數 d 從 1 起。
來源:UVa 10191 — Longest Nap。本敘述依原題規格重新撰寫。
範例測資
範例輸入 1
4 10:00 12:00 Lectures 12:00 13:00 Lunch, like always. 13:00 15:00 Boring lectures... 15:30 17:45 Reading 4 10:00 12:00 Lectures 12:00 13:00 Lunch, just lunch. 13:00 15:00 Lectures, lectures... oh, no! 16:45 17:45 Reading (to be or not to be?) 4 10:00 12:00 Lectures, as everyday. 12:00 13:00 Lunch, again!!! 13:00 15:00 Lectures, more lectures! 15:30 17:15 Reading (I love reading, but should I schedule it?) 1 12:00 13:00 I love lunch! Have you ever noticed it? :)
範例輸出 1
Day #1: the longest nap starts at 15:00 and will last for 30 minutes. Day #2: the longest nap starts at 15:00 and will last for 1 hours and 45 minutes. Day #3: the longest nap starts at 17:15 and will last for 45 minutes. Day #4: the longest nap starts at 13:00 and will last for 5 hours and 0 minutes.
請先登入後再提交程式碼
討論與題解
載入討論區…