

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 100 点
問題文
AtCoder 社は、オンラインショップでグッズを販売しています。
高橋君はそこで N 種類の商品を購入することにしました。
1 以上 N 以下の整数 i について、i 種類目の商品は 1 個 P_i 円で、高橋君は Q_i 個購入します。
また、高橋君は送料を支払う必要があります。
送料は購入する商品の合計金額が S 円以上なら 0 円、そうでないならば K 円です。
高橋君が支払う金額は購入する商品の合計金額と送料の和です。
高橋君が支払う金額を求めてください。
制約
- 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
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N S K P_1 Q_1 P_2 Q_2 \vdots P_N Q_N
出力
高橋君がオンラインショッピングで支払う金額を出力せよ。
入力例 1
2 2000 500 1000 1 100 6
出力例 1
2100
高橋君は 1 個 1000 円の商品を 1 個と、 1 個 100 円の商品を 6 つ購入します。
よって、購入する商品の合計金額は 1000\times 1+100\times 6=1600 円となります。
このとき購入する商品の合計金額は 2000 円未満であるため、送料は 500 円となります。
よって、高橋君の支払う金額は 1600+500=2100 円となります。
入力例 2
3 2000 500 1000 1 100 6 5000 1
出力例 2
6600
購入する商品の合計金額は 1000\times 1+100\times 6+5000\times 1=6600 円となります。
このとき購入する商品の合計金額は 2000 円以上であるため、送料は 0 円となります。
よって、高橋君の支払う金額は 6600+0=6600 円となります。
入力例 3
2 2000 500 1000 1 1000 1
出力例 3
2000
1 個あたりの価格が同じ商品が複数存在することもあります。
Score : 100 points
Problem Statement
AtCoder Inc. sells merchandise through its online shop.
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
Output
Print the amount Takahashi will pay for online shopping.
Sample Input 1
2 2000 500 1000 1 100 6
Sample 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.
Sample Input 2
3 2000 500 1000 1 100 6 5000 1
Sample 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.
Sample Input 3
2 2000 500 1000 1 1000 1
Sample Output 3
2000
There may be multiple products with the same price per item.