CF924E.Wardrobe

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Olya wants to buy a custom wardrobe. It should have nn boxes with heights a1,a2,...,ana_{1},a_{2},...,a_{n} , stacked one on another in some order. In other words, we can represent each box as a vertical segment of length aia_{i} , and all these segments should form a single segment from 00 to without any overlaps.

Some of the boxes are important (in this case bi=1b_{i}=1 ), others are not (then bi=0b_{i}=0 ). Olya defines the convenience of the wardrobe as the number of important boxes such that their bottom edge is located between the heights ll and rr , inclusive.

You are given information about heights of the boxes and their importance. Compute the maximum possible convenience of the wardrobe if you can reorder the boxes arbitrarily.

输入格式

The first line contains three integers nn , ll and rr ( 1<=n<=100001<=n<=10000 , 0<=l<=r<=100000<=l<=r<=10000 ) — the number of boxes, the lowest and the highest heights for a bottom edge of an important box to be counted in convenience.

The second line contains nn integers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 1<=ai<=100001<=a_{i}<=10000 ) — the heights of the boxes. It is guaranteed that the sum of height of all boxes (i. e. the height of the wardrobe) does not exceed 1000010000 : Olya is not very tall and will not be able to reach any higher.

The second line contains nn integers b1,b2,...,bnb_{1},b_{2},...,b_{n} ( 0<=bi<=10<=b_{i}<=1 ), where bib_{i} equals 11 if the ii -th box is important, and 00 otherwise.

输出格式

Print a single integer — the maximum possible convenience of the wardrobe.

输入输出样例

  • 输入#1

    5 3 6
    3 2 5 1 2
    1 1 0 1 0
    

    输出#1

    2
    
  • 输入#2

    2 2 5
    3 6
    1 1
    

    输出#2

    1
    

说明/提示

In the first example you can, for example, first put an unimportant box of height 22 , then put an important boxes of sizes 11 , 33 and 22 , in this order, and then the remaining unimportant boxes. The convenience is equal to 22 , because the bottom edges of important boxes of sizes 33 and 22 fall into the range [3,6][3,6] .

In the second example you have to put the short box under the tall box.

首页