Time Limit: 1000 MS Memory Limit: 65536 K
Little Fox Jiro received a box from his sister Fox Ciel as
a present. The box contained many cookies of various colors.
Jiro wants to eat as many of these cookies as possible.
The cookies are locked in a strange box. Jiro cannot take
cookies from the box directly. On the box there is a dial and
a button. These can be used to obtain cookies in the following
way:Jiro uses the dial to choose any pair of distinct colors
C1 and C2.Jiro pushes the button. If there are less than P1
cookies of color C1, nothing happens. Also, if there are less
than P2 cookies of color C2, nothing happens. Otherwise,
exactly P1 cookies of color C1 and exactly P2 cookies of color
C2 drop out of the box and Jiro eats all of them.
You are given a int cookies describing the initial contents
of the box: for each i, the box contains cookies[i] cookies
of color i. You are also given the ints P1 and P2. Your method
must return the maximum number of cookies Jiro can eat by
repeating above procedure optimally.
multiple test cases,each case begins with a integer n (1<=n<=50)which
denotes the length of the cookies array.Then n integers
Follows,the ith integer ai(50<=ai<=2000) indicates the ith element
of the cookies array.the next line contains two integers
For each case,output the maximum number of cookies Jiro can eat by repeating above procedure optimally.
50 250 50
50 250 250