ssaly_ 2021-12-20 20:05 采纳率: 100%
浏览 10
已结题

用Java语言怎么解决这个问题

Jenny's First Exam
Description

First exams cause many problems to Jenny. One problem is that Jenny needs the whole day to prepare for any exam (good news is she needs only one day for any preparation). Another problem: in a day of the exam Jenny is not able to study anything. And the main problem: Jenny must prepare for i-th exam not earlier then ti days before it, in the other case she forgets absolutely everything by the time of the exam.

Jenny wants to start preparations as later as possible but she has to pass all exams. Help Jenny to choose a day when she must start.

Input

The first line of the input file contains n (1 ≤ n ≤ 50 000) — the number of exams. The following lines describes exams.

Each description consists of three lines. The first line is the name of the subject (a string containing only Latin letters, maximal length is 10). The second line is the date of the exam in format dd.mm.yyyy. The third line contains ti for this exam (1 ≤ ti ≤ 100 000).

All exams take place in interval from 01.01.1900 to 31.12.2100.

Recall that if the year is divisible by 4 and is not divisible by 100, or is divisible by 400 — it is the leap one. Such year has 366 days, the additional day is on February 29.

Output

Output the latest date when Jenny may start preparation and pass all exams. Write date in format dd.mm.yyyy. If it is impossible to pass all the exams, output the word “Impossible”.

Sample Input

sample input #1
3
Philosophy
01.01.1900
1
Algebra
02.01.1900
3
Physics
04.01.1900
10

sample input #2
2
Philosophy
29.06.2005
1
Algebra
30.06.2005
2
Sample Output

sample output #1
30.12.1899

sample output #2
Impossible

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 12月28日
    • 创建了问题 12月20日

    悬赏问题

    • ¥15 这个m8复古游戏机游戏机该怎么安装游戏呢
    • ¥15 vxworks交叉编译gcc报错error: missing binary operator before token "("
    • ¥15 JSzip压缩文件时如何设置解压缩密码
    • ¥66 nuxtjs3 ,老是报错,内容:我有代码仓库,如何解决?
    • ¥30 WPF如何实现动态Y轴
    • ¥15 读取parquet文件某一列的数据但是输出是整个列名和格式
    • ¥15 机动目标 制导律建模问题
    • ¥100 求Java socks 转发实现Demo
    • ¥20 随身WiFi移动网络访问不了
    • ¥50 RAD_XE11.3获取android11手机的IMEI码