As you may already know, there are professors very busy with a filled schedule of work during the day. Your professor, let’s call him Professor P, is a bit lazy and wants to take a nap during the day, but as his schedule is very busy, he doesn’t have a lot of chances of doing this.
    He would REALLY like, however, to take one nap every day. Because he’ll take just one nap, he wants to take the longest nap that it’s possible given his schedule. He decided to write a program to help him in this task but, as we said, Professor P is very lazy. So, he finally decided that YOU must write the program!
Input
The input will consist on an arbitrary number of test cases, each test case represents one day.
    The first line of each set contains a positive integer s (not greater than 100) representing the number of scheduled appointments during that day. In the next s lines there are the appointments in the following format:
time1 time2 appointment
    Where time1 represents the time which the appointment starts and time2 the time it ends. All times will be in the ‘hh:mm’ format, time1 will always be strictly less than time2, they will be separated by a single space and all times will be greater than or equal to 10:00 and less than or equal to 18:00.
    So, your response must be in this interval as well (i.e. no nap can start before 10:00 and last after 18:00).
    The appointment can be any sequence of characters, but will always be in the same line. You can assume that no line will be longer than 255 characters, that 10 ≤ hh ≤ 18 and that 0 ≤ mm < 60.
    You CAN’T assume, however, that the input will be in any specific order. You must read the input until you reach the end of file.
Output
For each test case, you must print the following line:
Day #d: the longest nap starts at hh : mm and will last for [H hours and] M minutes.
Where d stands for the number of the test case (starting from 1) and hh : mm is the time when the nap can start. To display the duration of the nap, follow these simple rules:

  1. if the total duration X in minutes is less than 60, just print ‘M minutes’, where M = X.
  2. if the total duration X in minutes is greater or equal to 60, print ‘H hours and M minutes’, where

H = X ÷ 60 (integer division, of course) and M = X mod 60.
    Notice that you don’t have to worry with concordance (i.e. you must print ‘1 minutes’ or ‘1 hours’ if it’s the case).
    The duration of the nap is calculated by the difference between the ending time free and the begining time free. That is, if an appointment ends at 14:00 and the next one starts at 14:47, then you have (14:47)-(14:00) = 47 minutes of possible nap.
    If there is more than one longest nap with the same duration, print the earliest one. You can assume that there won’t be a day all busy (i.e. you may assume that there will be at least one possible nap).
Sample Input
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?

UVA10191 Longest Nap【排序】相关推荐

  1. ICPC程序设计题解书籍系列之八:(美)斯基纳等:《挑战编程-程序设计竞赛训练手册》

    S书<挑战编程--程序设计竞赛训练手册>题目一览 1 Getting Started UVA100 POJ1207 HDU1032 The 3n + 1 problem[水题] - 海岛B ...

  2. (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO

    下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发. 一.UVaOJ http://uva.onlinej ...

  3. UVa Online Judge 工具網站

    UVa Online Judge 工具網站 转自http://www.csie.ntnu.edu.tw/~u91029/uva.html Lucky貓的ACM園地,Lucky貓的 ACM 中譯題目 M ...

  4. 算法竞赛入门经典+挑战编程+USACO

    下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发. 一.UVaOJ http://uva.onlinej ...

  5. sicily题目分类

    sicily题目分类 1. 编程入门 2. 数据结构 3. 字符串 4. 排序 5. 图遍历 6. 图算法 7. 搜索:剪枝,启发式搜索 8. 动态规划/递推 9. 分治/递归 10. 贪心 11. ...

  6. [sicily]部分题目分类

    sicily题目分类 1. 编程入门 2. 数据结构 3. 字符串 4. 排序 5. 图遍历 6. 图算法 7. 搜索:剪枝,启发式搜索 8. 动态规划/递推 9. 分治/递归 10. 贪心 11. ...

  7. Sicily 题目分类

    依照自己水平挑着做→ →~~ 1. 编程入门 2. 数据结构 3. 字符串 4. 排序 5. 图遍历 6. 图算法 7. 搜索:剪枝,启发式搜索 8. 动态规划/递推 9. 分治/递归 10. 贪心 ...

  8. 编程题目分类(剪辑)

    1. 编程入门 2. 数据结构 3. 字符串 4. 排序 5. 图遍历 6. 图算法 7. 搜索:剪枝,启发式搜索 8. 动态规划/递推 9. 分治/递归 10. 贪心 11. 模拟 12. 算术与代 ...

  9. ACMer Training 学习指导

    本文原地址 一.UVaOJ http://uva.onlinejudge.org 西班牙Valladolid大学的程序在线评测系统,是历史最悠久.最著名的OJ. 二.<算法竞赛入门经典> ...

最新文章

  1. 语义分割--RefineNet: Multi-Path Refinement Networks for High-Resolution Semantic Segmentation
  2. 一个优秀的CIO,应该具备如何的知识体系和管理能力?
  3. MemSQL可以为时间序列应用做些什么
  4. DynamipsGUI下CISCO SDM的安装配置
  5. 2013年上半年工作总结,哇哈哈哈,给自己看的。
  6. CodeForces 173B Chamber of Secrets spfa
  7. Android之Toolbar的三个问题:修改左边箭头颜色、怎样修改右边以及子activity中的toolbar添加返回箭头...
  8. python计算工资编程-老男孩学Python编程后薪资待遇高吗?
  9. win10 系统 程序员计算器面板介绍和功能使用
  10. wps 字体对系统无效_wps 字体不显示怎么办 - 卡饭网
  11. 新手背代码被说“笨”?文科程序员教你如何记代码,妈妈再也不用担心我的头发!
  12. 1.SCRT怎么连接Ensp里面的设备???
  13. 89c51单片机流水灯操作
  14. 基于LM331的频率电压转换电路
  15. ng-include
  16. python 可以用excel做词云图嘛_word_cloud-用Python之作个性化词云图
  17. 混合精度训练、分布式训练等训练加速方法
  18. bga焊盘怎么做_BGA焊盘设计标准及基本规则是什么
  19. 观点丨企业需要一个什么样的独立云管平台?
  20. 【渝粤题库】陕西师范大学202511商法学 作业(高起本)

热门文章

  1. spring与web关系
  2. CGI与JSP联系与区别
  3. 一文带你实现RPC框架
  4. 在C#中使用自定义消息
  5. python变量作用域图解_图解python全局变量与局部变量相关知识
  6. Vue+ElementUI搭建一个后台管理框架
  7. MyBatis--动态插入多条数据
  8. Bug--WARN Please initialize the log4j system properly.
  9. html ios音乐自动播放muted,video下autoplay属性无效的解决方法(添加muted属性)
  10. Redis的复制(Master/Slave)