CF746F.Music in Car

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Sasha reaches the work by car. It takes exactly kk minutes. On his way he listens to music. All songs in his playlist go one by one, after listening to the ii -th song Sasha gets a pleasure which equals aia_{i} . The ii -th song lasts for tit_{i} minutes.

Before the beginning of his way Sasha turns on some song xx and then he listens to the songs one by one: at first, the song xx , then the song (x+1)(x+1) , then the song number (x+2)(x+2) , and so on. He listens to songs until he reaches the work or until he listens to the last song in his playlist.

Sasha can listen to each song to the end or partly.

In the second case he listens to the song for integer number of minutes, at least half of the song's length. Formally, if the length of the song equals dd minutes, Sasha listens to it for no less than minutes, then he immediately switches it to the next song (if there is such). For example, if the length of the song which Sasha wants to partly listen to, equals 55 minutes, then he should listen to it for at least 33 minutes, if the length of the song equals 88 minutes, then he should listen to it for at least 44 minutes.

It takes no time to switch a song.

Sasha wants to listen partly no more than ww songs. If the last listened song plays for less than half of its length, then Sasha doesn't get pleasure from it and that song is not included to the list of partly listened songs. It is not allowed to skip songs. A pleasure from a song does not depend on the listening mode, for the ii -th song this value equals aia_{i} .

Help Sasha to choose such xx and no more than ww songs for partial listening to get the maximum pleasure. Write a program to find the maximum pleasure Sasha can get from the listening to the songs on his way to the work.

输入格式

The first line contains three integers nn , ww and kk ( 1<=w<=n<=21051<=w<=n<=2·10^{5} , 1<=k<=21091<=k<=2·10^{9} ) — the number of songs in the playlist, the number of songs Sasha can listen to partly and time in minutes which Sasha needs to reach work.

The second line contains nn positive integers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 1<=ai<=1041<=a_{i}<=10^{4} ), where aia_{i} equals the pleasure Sasha gets after listening to the ii -th song.

The third line contains nn positive integers t1,t2,...,tnt_{1},t_{2},...,t_{n} ( 2<=ti<=1042<=t_{i}<=10^{4} ), where tit_{i} equals the length of the ii -th song in minutes.

输出格式

Print the maximum pleasure Sasha can get after listening to the songs on the way to work.

输入输出样例

  • 输入#1

    7 2 11
    3 4 3 5 1 4 6
    7 7 3 6 5 3 9
    

    输出#1

    12
    
  • 输入#2

    8 4 20
    5 6 4 3 7 5 4 1
    10 12 5 12 14 8 5 8
    

    输出#2

    19
    
  • 输入#3

    1 1 5
    6
    9
    

    输出#3

    6
    
  • 输入#4

    1 1 3
    4
    7
    

    输出#4

    0
    

说明/提示

In the first example Sasha needs to start listening from the song number 22 . He should listen to it partly (for 44 minutes), then listen to the song number 33 to the end (for 33 minutes) and then partly listen to the song number 44 (for 33 minutes). After listening to these songs Sasha will get pleasure which equals 4+3+5=124+3+5=12 . Sasha will not have time to listen to the song number 55 because he will spend 4+3+3=104+3+3=10 minutes listening to songs number 22 , 33 and 44 and only 11 minute is left after that.

首页