CF671E.Organizing a Race

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Kekoland is a country with nn beautiful cities numbered from left to right and connected by n1n-1 roads. The ii -th road connects cities ii and i+1i+1 and length of this road is wiw_{i} kilometers.

When you drive in Kekoland, each time you arrive in city ii by car you immediately receive gig_{i} liters of gas. There is no other way to get gas in Kekoland.

You were hired by the Kekoland president Keko to organize the most beautiful race Kekoland has ever seen. Let race be between cities ll and rr ( l<=rl<=r ). Race will consist of two stages. On the first stage cars will go from city ll to city rr . After completing first stage, next day second stage will be held, now racers will go from rr to ll with their cars. Of course, as it is a race, racers drive directly from start city to finish city. It means that at the first stage they will go only right, and at the second stage they go only left. Beauty of the race between ll and rr is equal to rl+1r-l+1 since racers will see rl+1r-l+1 beautiful cities of Kekoland. Cars have infinite tank so racers will take all the gas given to them.

At the beginning of each stage racers start the race with empty tank ( 00 liters of gasoline). They will immediately take their gasoline in start cities ( ll for the first stage and rr for the second stage) right after the race starts.

It may not be possible to organize a race between ll and rr if cars will run out of gas before they reach finish.

You have kk presents. Each time you give a present to city ii its value gig_{i} increases by 11 . You may distribute presents among cities in any way (also give many presents to one city, each time increasing gig_{i} by 11 ). What is the most beautiful race you can organize?

Each car consumes 11 liter of gas per one kilometer.

输入格式

The first line of the input contains two integers nn and kk ( 2<=n<=1000002<=n<=100000 , 0<=k<=1090<=k<=10^{9} ) — the number of cities in Kekoland and the number of presents you have, respectively.

Next line contains n1n-1 integers. The ii -th of them is wiw_{i} ( 1<=wi<=1091<=w_{i}<=10^{9} ) — the length of the road between city ii and i+1i+1 .

Next line contains nn integers. The ii -th of them is gig_{i} ( 0<=gi<=1090<=g_{i}<=10^{9} ) — the amount of gas you receive every time you enter city ii .

输出格式

Print a single line — the beauty of the most beautiful race you can organize.

输入输出样例

  • 输入#1

    4 4
    2 2 2
    1 1 1 1
    

    输出#1

    4
    
  • 输入#2

    8 5
    2 2 2 3 7 3 1
    1 3 1 5 4 0 2 5
    

    输出#2

    7
    

说明/提示

In first sample if you give one present to each city then it will be possible to make a race between city 11 and city 44 .

In second sample you should add 11 to g5g_{5} and 44 to g6g_{6} , then it will be possible to make a race between cities 22 and 88 .

首页