Problem H
Sausage Slicing
Sausages are produced in long chains. Bjørnar the butcher has $A$ customers in a group of customers that value the nutritional contents of a sausage, and $B$ customers that value the taste. Every member in the same group has attributed a single number to each individual sausage which is how much someone in that group values it. When considering a set of sausages, a customer will value it the same as the sum of the value of each individual sausage. Bjørnar will use the minimal amount of slices such that the original string of sausages will be divided into precisely $A+B$ contiguous segments, one for each customer.
The customers will think the butcher is giving some customers special treatment if he does not divide the sausages fairly. The $A+B$ customers think the division is fair if they each receive sausages with a value at least $\frac{1}{A+B}$ of the total value of the sausages based on their own evaluations. Is it possible for the sausages to be distributed fairly using the minimal number of chops?
Input
The first line contains $N$, the number of sausages, $A$, the number of people in the first group, and $B$, the number of people in the second group. The second line contains $N$ integers $a_ i$, which is how much each person in the first group values the $i$th sausage. The third line contains $N$ integers $b_ i$, which is how much each person in the second group values the $i$th sausage.
Output
If the sausages can be divided fairly print “yes”, otherwise print “no”.
Limits
-
$1 < N \leq 100$
-
$0 < A, B \leq 25$
-
$0 \leq a_ i, b_ i \leq 1000$
Sample Input 1 | Sample Output 1 |
---|---|
5 2 2 25 25 25 0 25 0 50 0 50 0 |
yes |
Sample Input 2 | Sample Output 2 |
---|---|
5 2 2 25 24 24 3 24 0 50 0 50 0 |
no |