CF366C.Dima and Salad
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Dima, Inna and Seryozha have gathered in a room. That's right, someone's got to go. To cheer Seryozha up and inspire him to have a walk, Inna decided to cook something.
Dima and Seryozha have n fruits in the fridge. Each fruit has two parameters: the taste and the number of calories. Inna decided to make a fruit salad, so she wants to take some fruits from the fridge for it. Inna follows a certain principle as she chooses the fruits: the total taste to the total calories ratio of the chosen fruits must equal k. In other words,
, where a__j is the taste of the j-th chosen fruit and b__j is its calories.
Inna hasn't chosen the fruits yet, she is thinking: what is the maximum taste of the chosen fruits if she strictly follows her principle? Help Inna solve this culinary problem — now the happiness of a young couple is in your hands!
Inna loves Dima very much so she wants to make the salad from at least one fruit.
季马、因娜和谢尔盖聚集在一间屋子里。没错,总得有人出去走走。为了安慰谢尔盖并激励他出门散步,因娜决定做点好吃的。
季马和谢尔盖的冰箱里共有 $ n $ 个水果。每个水果有两个参数:味道值(taste)和热量值(calories)。因娜打算制作一份水果沙拉,因此她想从冰箱中挑选一些水果。她在挑选水果时遵循一个特定原则:所选水果的总味道值与总热量值之比必须恰好等于 $ k $。换言之,
,
其中 $ a_j $ 表示第 $ j $ 个被选中的水果的味道值,$ b_j $ 表示其热量值。
因娜尚未选定水果,她正在思考:在严格遵守该原则的前提下,所能获得的最大总味道值是多少?请帮助因娜解决这一烹饪难题——如今,一对年轻情侣的幸福就掌握在你的手中!
因娜非常爱季马,因此她希望沙拉中至少包含一个水果。
输入格式
The first line of the input contains two integers n, k (1 ≤ n ≤ 100, 1 ≤ k ≤ 10). The second line of the input contains n integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 100) — the fruits' tastes. The third line of the input contains n integers _b_1, _b_2, ..., b__n (1 ≤ b__i ≤ 100) — the fruits' calories. Fruit number i has taste a__i and calories b__i.
输入的第一行包含两个整数 n、k(1 ≤ n ≤ 100,1 ≤ k ≤ 10)。
输入的第二行包含 n 个整数 a1, a2, ..., an(1 ≤ ai ≤ 100)—— 各水果的味道值。
输入的第三行包含 n 个整数 b1, b2, ..., bn(1 ≤ bi ≤ 100)—— 各水果的热量值。
第 i 个水果的味道值为 ai,热量值为 bi。
输出格式
If there is no way Inna can choose the fruits for the salad, print in the single line number -1. Otherwise, print a single integer — the maximum possible sum of the taste values of the chosen fruits.
如果伊娜无法选择水果制作沙拉,则在单独一行中输出数字 -1。否则,输出一个整数——所选水果的味道值之和的最大可能值。
输入输出样例
输入#1
3 2 10 8 1 2 7 1
输出#1
18
输入#2
5 3 4 4 4 4 4 2 2 2 2 2
输出#2
-1
说明/提示
In the first test sample we can get the total taste of the fruits equal to 18 if we choose fruit number 1 and fruit number 2, then the total calories will equal 9. The condition
fulfills, that's exactly what Inna wants.
In the second test sample we cannot choose the fruits so as to follow Inna's principle.
在第一个测试样例中,如果我们选择第 1 号水果和第 2 号水果,则水果的总美味值为 18,此时总热量为 9。条件
得以满足,而这正是 Inna 所期望的。
在第二个测试样例中,我们无法选择水果以满足 Inna 的原则。
输入解题思路,AI测评打分。不知道怎么写?