CF924E.Wardrobe
省选/NOI-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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
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.
奥莉娅想定制一个衣柜。该衣柜应包含 n 个高度分别为 a1,a2,…,an 的箱子,以某种顺序自下而上堆叠。换言之,每个箱子可表示为一条长度为 ai 的垂直线段,所有这些线段应无缝拼接成一条从 0 到
的连续线段(无重叠)。
其中部分箱子是重要的(此时 bi=1),其余则不重要(此时 bi=0)。奥莉娅将衣柜的“便利性”定义为:底边位于高度区间 [l,r](含端点)内的重要箱子的数量。
已知各箱子的高度及其重要性标识。若你可以任意重排这些箱子的顺序,求衣柜所能达到的最大便利性。
输入格式
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.
第一行包含三个整数 n、l 和 r(1≤n≤10000,0≤l≤r≤10000)——分别表示箱子的数量、重要箱子底边高度的下界与上界(仅当重要箱子底边高度在此范围内时,才计入便利性统计)。
第二行包含 n 个整数 a1,a2,…,an(1≤ai≤10000)——表示各箱子的高度。保证所有箱子高度之和(即衣柜总高度)不超过 10000:奥莉娅身高有限,无法触及更高处。
第三行包含 n 个整数 b1,b2,…,bn(0≤bi≤1),其中 bi=1 表示第 i 个箱子是重要的,否则为 0。
输出格式
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 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.
在第一个例子中,你可以例如先放置一个高度为 2 的不重要盒子,然后按顺序放置尺寸分别为 1、3 和 2 的重要盒子,最后再放置剩余的不重要盒子。便利值等于 2,因为尺寸为 3 和 2 的重要盒子的底边落在区间 [3, 6] 内。
在第二个例子中,你必须将矮盒子放在高盒子下方。
输入解题思路,AI测评打分。不知道怎么写?