#abc331b. B - Buy One Carton of Milk

B - Buy One Carton of Milk

Score : 200200 points

问题描述

一家超市出售鸡蛋包装。

一包包含6个鸡蛋的价格是S日元,一包包含8个鸡蛋的价格是M日元,而一包包含12个鸡蛋的价格是L日元。

在你可以购买任意数量的每种包装的情况下,找出至少购买N个鸡蛋所需的最少金额。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

A supermarket sells egg packs.

A pack of 66 eggs costs SS yen, a pack of 88 eggs costs MM yen, and a pack of 1212 eggs costs LL yen.

When you can buy any number of each pack, find the minimum amount of money required to purchase at least NN eggs.

Constraints

  • 1N1001 \leq N \leq 100
  • 1S,M,L1041 \leq S,M,L \leq 10^4
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN SS MM LL

Output

Print the answer.

Sample Input 1

16 120 150 200

Sample Output 1

300

It is optimal to buy two 88-egg packs.

Sample Input 2

10 100 50 10

Sample Output 2

10

It is optimal to buy one 1212-egg pack.

Sample Input 3

99 600 800 1200

Sample Output 3

10000

It is optimal to buy five 88-egg packs and five 1212-egg packs.

update @ 2024/3/10 01:15:13