Buy One Carton of Milk

AtCoder
IDabc331_b
Time2000ms
Memory256MB
Difficulty
A supermarket sells egg packs. A pack of $6$ eggs costs $S$ yen, a pack of $8$ eggs costs $M$ yen, and a pack of $12$ eggs costs $L$ yen. When you can buy any number of each pack, find the minimum amount of money required to purchase at least $N$ eggs. ## Constraints * $1 \leq N \leq 100$ * $1 \leq S,M,L \leq 10^4$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $N$ $S$ $M$ $L$ [samples]
Samples
Input #1
16 120 150 200
Output #1
300

It is optimal to buy two $8$\-egg packs.
Input #2
10 100 50 10
Output #2
10

It is optimal to buy one $12$\-egg pack.
Input #3
99 600 800 1200
Output #3
10000

It is optimal to buy five $8$\-egg packs and five $12$\-egg packs.
API Response (JSON)
{
  "problem": {
    "name": "Buy One Carton of Milk",
    "description": {
      "content": "A supermarket sells egg packs. A pack of $6$ eggs costs $S$ yen, a pack of $8$ eggs costs $M$ yen, and a pack of $12$ eggs costs $L$ yen. When you can buy any number of each pack, find the minimum amo",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc331_b"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "A supermarket sells egg packs.\nA pack of $6$ eggs costs $S$ yen, a pack of $8$ eggs costs $M$ yen, and a pack of $12$ eggs costs $L$ yen.\nWhen you can buy any number of each pack, find the minimum amo...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments