#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 nn 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 rr and a price pp . With a travel card of range rr Jerry may travel no more than rr stops at once. Therefore, if Jerry enters metro at the stop ii he should exit on one of the stops from iri − r to i+ri + r inclusive. It takes did_{i} 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 tt minutes.

输入格式

The first line of the input file contains two integers nn and tt -- the number of stops and the maximum possible time (2n50000(2 \le n \le 50 000 ; n1t109).n - 1 \le t \le 10^{9}).

The second line contains n1n - 1 integers prp_{r} -- the prices of travel cards with range r=1r = 1 . . . n1(1pr100000)n − 1 (1 \le p_{r} \le 100 000)

The third line contains n2n - 2 integers did_{i} -- the number of minutes required to reenter metro at stop i=2i = 2 . . . n1(1di105).n - 1 (1 \le d_{i} \le 10^{5}).

输出格式

Output a single integer pp -- the lowest possible price of one travel card that allows Jerry to travel from the first to the last stop in no more than tt minutes.

4 4
1 2 3
1 4

2

提示

Time limit: 2 s, Memory limit: 256 MB.