Online Shopping

AtCoder
IDabc332_a
Time2000ms
Memory256MB
Difficulty
AtCoder Inc. sells merchandise through its [online shop](https://suzuri.jp/AtCoder/home). Takahashi has decided to purchase $N$ types of products from there. For each integer $i$ from $1$ to $N$, the $i$\-th type of product has a price of $P_i$ yen each, and he will buy $Q_i$ of this. Additionally, he must pay a shipping fee. The shipping fee is $0$ yen if the total price of the products purchased is $S$ yen or above, and $K$ yen otherwise. He will pay the total price of the products purchased plus the shipping fee. Calculate the amount he will pay. ## Constraints * $1\leq N\leq 100$ * $1\leq S\leq 10000$ * $1\leq K\leq 10000$ * $1\leq P_i\leq 10000$ * $1\leq Q_i\leq 100$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $N$ $S$ $K$ $P_1$ $Q_1$ $P_2$ $Q_2$ $\vdots$ $P_N$ $Q_N$ [samples]
Samples
Input #1
2 2000 500
1000 1
100 6
Output #1
2100

Takahashi buys one product for $1000$ yen and six products for $100$ yen each.  
Thus, the total price of the products is $1000\times 1+100\times 6=1600$ yen.  
Since the total amount for the products is less than $2000$ yen, the shipping fee will be $500$ yen.  
Therefore, the amount Takahashi will pay is $1600+500=2100$ yen.
Input #2
3 2000 500
1000 1
100 6
5000 1
Output #2
6600

The total price of the products is $1000\times 1+100\times 6+5000\times 1=6600$ yen.  
Since the total amount for the products is not less than $2000$ yen, the shipping fee will be $0$ yen.  
Therefore, the amount Takahashi will pay is $6600+0=6600$ yen.
Input #3
2 2000 500
1000 1
1000 1
Output #3
2000

There may be multiple products with the same price per item.
API Response (JSON)
{
  "problem": {
    "name": "Online Shopping",
    "description": {
      "content": "AtCoder Inc. sells merchandise through its [online shop](https://suzuri.jp/AtCoder/home). Takahashi has decided to purchase $N$ types of products from there.   For each integer $i$ from $1$ to $N$, th",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc332_a"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "AtCoder Inc. sells merchandise through its [online shop](https://suzuri.jp/AtCoder/home).\nTakahashi has decided to purchase $N$ types of products from there.  \nFor each integer $i$ from $1$ to $N$, th...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments