spoj#MGCSCLS. Bob and magical scale
Bob and magical scale
当前没有测试数据。
Small Bob received scales with magical bricks. They are magical because they can have minus weight.
His mom made L towers on the left arm and P towers on the right arm of the scale. Every tower is made with exactly N bricks.
She asked him how many brick he has to put off from each arm to balance the scale. Obviously Bob can only take bricks from top of the tower and he can't put back taken off bricks.It's too difficult for him.Can you help him solve it in minimum number of moves?
Input
In first line number N,L,P . Number of bricks in every tower. Number of towers on left arm and Number of towers on right arm.
In next L lines: construction of towers on the left arm.
In next P lines: construction of towers on the right arm. ( look at picture )
N<=50
L<=25
P<=25
-50<=weight of every brick<=50
Output
Minimal number of moves to balance the scale.
Example
2 2 2 4 3 -1 2 7 3 1 -2Output: 2
I made timelimit so high because i want all correct solutions to get accepted, but not n! solution.