今天是愛麗絲的生日!為了慶祝生日,她去了一間高檔餐廳吃晚餐。由於這是她第一次去高檔餐廳吃晚餐,她感到十分興奮,所以點了很多食物。
可是,她發現她點了太多食物,她沒有辦法吃光它們。由於桌上有太多剩菜,她又不想浪費食物,她決定把剩菜打包,留到以後在家吃。
為了打包食物,愛麗絲向侍應拿了一些打包盒。她有 個可以載 單位食物的打包盒, 個可以載 單位食物的打包盒, 個可以載 單位食物的打包盒和 個可以載 單位食物的打包盒。桌上有 道菜,第 道菜還剩下 單位的食物。
她想按照下面的規則盡可能打包更多單位的食物:
她想知道她可以盡可能打包多少單位的食物。你能幫幫她嗎?
Today is Alice's birthday! To celebrate it, she went to a high-end restaurant to have dinner. As it was her first time having dinner in an expensive restaurant, she felt very excited and ordered a lot of foods.
However, she found that she has ordered too many foods and she could not finish all of them. As there are too many leftovers on the table and she does not want to waste them, she decided to wrap the leftovers up and eat them at home in the future.
Alice has got some to-go boxes from the server for the leftovers. She has to-go boxes that can hold unit of foods, to-go boxes that can hold units of foods, to-go boxes that can hold units of foods, and to-go boxes that can hold units of foods. There are also dishes that Alice cannot finish. For the dish, there is units of food left.
She is trying to wrap up as many units of food as possible following these rules:
She wants to know what is the maximum amount of units of foods she can wrap up. Can you help her?
第一行有五個整數 , , , 和 ,菜的數量和能載 、、、 單位食物的打包盒的數量。
第二行有 個整數 ,愛麗絲吃剩的第 道菜的單位。
The first line consists of 5 integers: , , , , and . These integers represent the number of dishes and the number of to-go boxes with capacities of , , , and units, respectively.
The second line contains integers , the number of units of the dish that Alice cannot finish.
輸出一個整數,愛麗絲可以打包的最大食物單位數量。
Output an integer, the maximum amount of units of foods that Alice can wrap up.
4 0 0 2 0
1 1 2 3
5
4 0 0 0 2
2 2 1 1
6
樣例 1︰分別打包第三和第四道菜到能載 單位食物的打包盒。
樣例 2︰打包第一和第三道菜到一個能載 單位食物的打包盒,然後打包剩餘的到另一個能載 單位食物的打包盒。
Sample 1: Pack the and dish into -unit to-go boxes, respectively.
Sample 2: Pack the and dish into a -unit to-go box, and pack the rest into another -unit to-go box.
對於全部測試數據,滿足:,,。
子任務 | 分數 | 附加限制 |
---|---|---|
, | ||
, | ||
, | ||
無附加限制 |
For all test data, , , .
Subtask | Score | Additional Constraints |
---|---|---|
, | ||
, | ||
, | ||
No additional constraints |