VK Cup 2018 - Round 2
E
Wardrobe
Codeforces
2700
原题
← DF →
翻译中…

Olya wants to buy a custom wardrobe. It should have $*n*$ boxes with heights $*a*_{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 $*a*_{*i*}$, and all these segments should form a single segment from $0$ to image without any overlaps.

翻译中…

Some of the boxes are important (in this case $*b*_{*i*} = 1$), others are not (then $*b*_{*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 $*l*$ and $*r*$, 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.

翻译中…

Input

翻译中…

The first line contains three integers $*n*$, $*l*$ and $*r*$ ($1 ≤ *n* ≤ 10 000$, $0 ≤ *l* ≤ *r* ≤ 10 000$) — 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 $*n*$ integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ ($1 ≤ *a*_{*i*} ≤ 10 000$) — 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 $10 000$: Olya is not very tall and will not be able to reach any higher.

翻译中…

The second line contains $*n*$ integers $*b*_{1}, *b*_{2}, ..., *b*_{*n*}$ ($0 ≤ *b*_{*i*} ≤ 1$), where $*b*_{*i*}$ equals $1$ if the $*i*$-th box is important, and $0$ otherwise.

翻译中…

Output

翻译中…

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

翻译中…

Note

翻译中…

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

翻译中…

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

翻译中…

样例

Input #1
5 3 6
3 2 5 1 2
1 1 0 1 0
Output #1
2
InputCopy OutputCopy
Input #2
2 2 5
3 6
1 1
Output #2
1
InputCopy OutputCopy
题目信息
题号
924E
时间限制
1 s
内存限制
256 MB
标签
动态规划
贪心

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。