OpenJudge

3788:Priest John's Busiest Day

总时间限制:
2000ms
内存限制:
65536kB
描述

John is the only priest in his town. September 1st is the John's busiest day in a year because there is an old legend in the town that the couple who get married on that day will be forever blessed by the God of Love. This year N couples plan to get married on the blessed day. The i-th couple plan to hold their wedding from time Si to time Ti. According to the traditions in the town, there must be a special ceremony on which the couple stand before the priest and accept blessings. The i-th couple need Di minutes to finish this ceremony. Moreover, this ceremony must be either at the beginning or the ending of the wedding (i.e. it must be either from Si to Si + Di, or from Ti - Di to Ti). Could you tell John how to arrange his schedule so that he can present at every special ceremonies of the weddings.

Note that John can not be present at two weddings simultaneously.

输入

The first line contains a integer N ( 1 ≤ N ≤ 1000).
The next N lines contain the Si, Ti and Di. Si and Ti are in the format of hh:mm.

输出

The first line of output contains "YES" or "NO" indicating whether John can be present at every special ceremony. If it is "YES", output another N lines describing the staring time and finishing time of all the ceremonies.

样例输入
2
08:00 09:00 30
08:15 09:00 20

样例输出
YES
08:00 08:30
08:40 09:00
提示
If one ceremony ends at the same time another begins, they are not considered simultaneous.
全局题号
2789
添加于
2009-10-29
提交次数
256
尝试人数
54
通过人数
36
您的评价 很水 简单 一般 较难 变态
  • 标签(多个标签用空格分隔):
  • 常用标签:
    递归   动态规划   贪心   搜索   枚举   模拟   数学   字符串处理   几何   高精度计算   图论  

共有3人评分

33.3%
33.3%
0.0%
0.0%
33.3%

已有的标签

剪枝(1) 搜索(1) 枚举(1) 2-SAT,tarjan求强联(1) 2—SAT(1)