#abc332a. A - Online Shopping

A - Online Shopping

Score : 100100 points

问题描述

AtCoder Inc. 通过其线上商店销售商品。

高桥决定从那里购买 NN 种不同类型的商品。
对于从 11NN 的每个整数 ii,第 ii 类商品的单价为 PiP_i 日元,他将购买 QiQ_i 件该商品。

另外,他还必须支付运费。
如果购买商品的总价达到或超过 SS 日元,则运费为 00 日元,否则运费为 KK 日元。

他需要支付购买商品的总价加上运费。
请计算他总共需要支付的金额。

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

Problem Statement

AtCoder Inc. sells merchandise through its online shop.

Takahashi has decided to purchase NN types of products from there.
For each integer ii from 11 to NN, the ii-th type of product has a price of PiP_i yen each, and he will buy QiQ_i of this.

Additionally, he must pay a shipping fee.
The shipping fee is 00 yen if the total price of the products purchased is SS yen or above, and KK yen otherwise.

He will pay the total price of the products purchased plus the shipping fee.
Calculate the amount he will pay.

Constraints

  • 1N1001\leq N\leq 100
  • 1S100001\leq S\leq 10000
  • 1K100001\leq K\leq 10000
  • 1Pi100001\leq P_i\leq 10000
  • 1Qi1001\leq Q_i\leq 100
  • All input values are integers.

Input

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

NN SS KK

P1P_1 Q1Q_1

P2P_2 Q2Q_2

\vdots

PNP_N QNQ_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 10001000 yen and six products for 100100 yen each.
Thus, the total price of the products is 1000×1+100×6=16001000\times 1+100\times 6=1600 yen.
Since the total amount for the products is less than 20002000 yen, the shipping fee will be 500500 yen.
Therefore, the amount Takahashi will pay is 1600+500=21001600+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×1+100×6+5000×1=66001000\times 1+100\times 6+5000\times 1=6600 yen.
Since the total amount for the products is not less than 20002000 yen, the shipping fee will be 00 yen.
Therefore, the amount Takahashi will pay is 6600+0=66006600+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.

update @ 2024/3/10 01:16:46