
96  ZOJ Monthly, September 2010  D
Here comes the new term. In this new term, there are N new students who enter Nobita's primary school. The president is busy with the classes division. Right now he is considering what is the best way to divide N students into no more than K classes so that they may cause the least amount of unhappiness in total. But how to define and forecast the unhappiness students will cause in future? That's a question. Fortunately, Doraemon is nearly omnipotent. He tells the president that he can use an integer to describe a student's sentiment index, x_{i} for the ith student. Let L be the average of x_{i} (i = 1, 2, ..., N). To simplify the problem, if L is not an integer, let it be the floor of itself. If the ith student is sent into the kth class, he will cause (x_{i}  L)^{2} * g_{k} units of unhappiness. Don't worry about the value of g_{k} (k = 1, 2, ..., K), Doraemon can also tell them to the president. Now it's the president's turn to determine the division. For some special reasons, the division should obey these following rules.
The president can not find out the best division, so he turns to you for help. Remember that the total amount of unhappiness students cause is the sum of unhappiness each student causes. Your job is to figure out the minimum total amount of unhappiness and the best division. To simplify the problem, you are only asked to tell the number of classes K1 and the number of students in the K1th class T. InputThere are multiple cases. For each case, there are three lines. In the first line, there are four integers, N (1 <= N <= 10000), K (1 <= K <= 200), A (1 <= A <= N) and B (A <= B <= N), describe as above. The next line contains N integers, x_{1}, x_{2}, ... , x_{N} (1 <= x_{i} <= 100000). The last line contains K integers, g_{1}, g_{2}, ... , g_{K} (1000 <= g_{i} <= 1000). OutputFor each case, if there is no solution, output "No solution." in one line; otherwise, output three integers in a single line. The first is the minimum total amount of unhappiness. The second is the number of classes K1 follows, if there are multiple solutions to get the minimum total amount, output the smaller K1. Last is the number of students in the last class T, if there are still multiple solutions, output the smaller T. There is a blank between cases. Sample Input10 3 1 4 16 11 12 13 10 15 16 17 18 14 4 5 1 Sample Output186 3 4 Author: MO, Luyi Contest: ZOJ Monthly, September 2010 