#P7057. [NWRRC 2015] Journey to the “The World’s Start”
[NWRRC 2015] Journey to the “The World’s Start”
题目描述
Jerry Prince is the fourth grade student and he goes to New-Lodnon to visit the most popular amusement park The World's Start.
An airport he arrives at is next to the first stop of the metro line. This line has stops and The World's Start is on the last of them. The metro of New-Lodnon is pretty fast so you may assume that you can get from a stop to the next one in just one minute.
Jerry needs a travel card to use the metro. Each travel card has a range and a price . With a travel card of range Jerry may travel no more than stops at once. Therefore, if Jerry enters metro at the stop he should exit on one of the stops from to inclusive. It takes minutes to exit and reenter metro at i-th stop. There is no time required to enter the first stop or exit the last one.
Jerry is not very rich but he has some spare time, so he decided to buy the cheapest travel card that will allow him to travel from the first metro stop to the last one in no more than minutes.
输入格式
The first line of the input file contains two integers and -- the number of stops and the maximum possible time ;
The second line contains integers -- the prices of travel cards with range . . .
The third line contains integers -- the number of minutes required to reenter metro at stop . . .
输出格式
Output a single integer -- the lowest possible price of one travel card that allows Jerry to travel from the first to the last stop in no more than minutes.
4 4
1 2 3
1 4
2
提示
Time limit: 2 s, Memory limit: 256 MB.