Shaktimaan and Coupons

0

0 votes
Problem

Shaktimaan after saving the whole city got X coupons of type 1 and Y coupons of type 2,  which he can utilise on buying from N different products whose prices is given to you, the discounted coupons are of two types- 

1) This coupon allows to buy anything with value X, as X-sub, where sub is given, but if X<sub, then price only becomes 0,for eg- if price is 35 and sub is 10 then he buys it with price 25 and if sub is 50 then he buys it with price 0.

2) This coupon brings down the value of any product X to floor(X/div), where div is given, for eg if price is 98 and div is 3 then he buys it with price 32.

Also you can use only one kind of coupon on a particular item. Also all the coupons must be used. Shaktiman needs to buy x+y items. Tell Shaktimaan the minimum amount of money he need to spend from his pocket when he buys from given N products.

Constraints

1 <= N,A,B <= 2000

2 <= A+B <= N

1<= Sub, Div <= 1000000000

 

Input Format

First line containing N, X, Y, Sub, Div.

Second line contains N integers denoting prices of products .

Output Format

Print single integer denoting minimum sum.

 

Time Limit: 3
Memory Limit: 256
Source Limit:
Explanation

 

  • Take product 3 and 5 and apply coupon 1 on them.
  • Take product 2 and 4 and apply coupon 2 on them.

Therefore, total price to be paid = (76-9)+(29-9)+(54/1)+(53/1) = 194.

Editor Image

?