There are n battlefields with weights w_1, ..., w_n. You have B troops to distribute among them as non-negative integers. You win a battlefield if you place strictly more troops on it than your opponent; ties go to the opponent. You win the war if the total weight of the battlefields you win is strictly more than half of the total weight.
You will face a panel of K opponents, each equally likely. Your intelligence reports each opponent's planned allocation o_k, but it is imperfect: on every battlefield f, opponent k actually fields max(o_{k,f} + e, 0) troops, where e is drawn uniformly from the integers -d_k, ..., d_k, independently across battlefields.
Choose one allocation to face the whole panel.
The first line contains n, B and K. The second line contains the weights w_1, ..., w_n. The third line contains the noise half-widths d_1, ..., d_K. Each of the next K lines contains one opponent's planned allocation: n non-negative integers.
n non-negative integers summing to at most B: your allocation.
Your score is the average over the K opponents of the probability that your allocation wins the war against that opponent.
5 <= n <= 40
n <= B <= 500
10 <= K <= 200
1 <= w_i <= 100
0 <= d_k <= B / 10
Every opponent's planned allocation sums to at most B.
5 20 10 60 35 20 83 30 2 2 1 2 2 1 1 1 1 2 3 2 2 6 3 7 0 0 10 3 6 4 2 8 0 6 0 2 9 3 0 0 0 16 0 7 3 2 8 0 7 0 2 8 3 6 0 2 9 3 7 7 1 0 3 6 0 2 9 3
5 3 2 7 3
8 50 12 8 82 59 64 46 74 79 88 5 1 4 2 5 4 3 2 2 2 4 2 1 6 4 6 5 7 6 9 1 0 8 10 0 10 10 11 1 11 7 8 0 0 10 13 0 12 0 8 7 0 11 12 0 16 0 0 0 0 15 17 1 12 0 9 5 11 0 12 0 12 7 9 0 9 0 13 1 10 8 7 6 8 0 10 19 15 7 2 1 0 1 4 0 12 9 9 7 0 0 13 1 0 7 7 5 10 10 10 1 9 6 0 6 8 10 10
7 7 6 6 6 6 6 6