|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||512 MB||10||3||3||30.000%|
In the free-market, ruthlessly capitalist world of train fares, only one thing matters: incentives.
Train companies are incentivised with bonuses for high throughput, successful journeys, and customer satisfaction. Conversely, the companies are disincentivised from failure via mandatory refunds for customers delayed by 30 minutes or more.
Being a ruthless capitalist yourself, you have decided to take advantage of this generous delay compensation provision.
The refund is awarded provided that no matter the combination of trains you had taken (provided they followed the same route of stations as planned), you would still be unable to reach your destination in strictly less time than 30 minutes (or 1800 seconds), of the time you would have arrived assuming your booked journey was exactly on time.
Armed with your printout of the day’s delays, and the original timetable, you must ask yourself only one question: what is the earliest time you can book a train for from station 1, in order to earn this restitutive reward?
Stations are numbered from 1 to N in the order you will visit them. Each train goes between stations X and X + 1. It is possible to change between trains instantanesouly.
2 3 1 1800 9000 1800 1 2000 9200 1600 1 2200 9400 1400
2 2 1 1800 3600 1800 1 1900 3600 1600
3 2 1 10 20 1 2 20 30 0