CF366C Dima and Salad

题目描述

有 $n$ 个水果,每个水果有两个属性:美味值和卡路里值。现在选用若干个(至少 $1$ 个)水果制作一份特殊的沙拉,沙拉的美味值为所选的水果的美味值的和,沙拉的卡路里值为所选水果的卡路里值的和。沙拉的美味值恰好是卡路里值的 $K$ 倍。请计算该沙拉美味值最大为多少。

输入格式

第一行,两个整数 $n, k$($1 \le n \le 100$,$1 \le k \le 10$); 第二行,包含 $n$ 个整数 $a_1, a_2, \ldots, a_n$($1 \le a_i \le 100$),表示水果的美味值; 第三行,包含 $n$ 个整数 $b_1, b_2, \ldots, b_n$($1 \le b_i \le 100$),表示水果的卡路里值。

输出格式

共一行,一个整数,表示最大美味值,若无解则输出 `-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 ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF366C/ce55a230ecc0a3ebd10e969b3c18a14fbf3f32d3.png) fulfills, that's exactly what Inna wants. In the second test sample we cannot choose the fruits so as to follow Inna's principle.