102100: [AtCoder]ABC210 A - Cabbages

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $100$ points

Problem Statement

Takahashi is visiting a shop specializing in cabbage.

The shop sells cabbage for $X$ yen (Japanese currency) per head.
However, if you buy more than $A$ heads of cabbage at once, the $(A+1)$-th and subsequent heads will be sold for $Y$ yen per head.
(It is guaranteed that $Y \lt X$. See Sample Input/Output 1 for clarity.)

Print the amount of money needed to buy $N$ heads of cabbage.

Constraints

  • $1 \leq N \leq 10^5$
  • $1 \leq A \leq 10^5$
  • $1 \leq Y \lt X \leq 100$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

$N$ $A$ $X$ $Y$

Output

Print the amount of money needed to buy $N$ heads of cabbage (as an integer).


Sample Input 1

5 3 20 15

Sample Output 1

90

You need to pay $20$ yen for each of the $1$-st through $3$-rd heads of cabbage, and $15$ yen for each of the $4$-th and $5$-th heads of cabbage.
Thus, you need to pay a total of $20+20+20+15+15 = 90$ yen for the $5$ heads of cabbage.


Sample Input 2

10 10 100 1

Sample Output 2

1000

Input

题意翻译

高桥要买 $n$ 个卷心菜,已知前 $a$ 个卷心菜 $x$ 元一个,从第 $(a+1)$ 个卷心菜开始 $y$ 元一个。求高桥要花的钱数。

Output

分数:100分

问题描述

高桥正在参观一家专门卖卷心菜的商店。

该店每颗卷心菜售价为X日元(日本货币)。
但是,如果你一次购买超过A颗卷心菜,第A+1颗及之后的卷心菜将按每颗Y日元的价格出售。
(保证Y

请打印出购买N颗卷心菜所需的钱数。

限制条件

  • $1 \leq N \leq 10^5$
  • $1 \leq A \leq 10^5$
  • $1 \leq Y \lt X \leq 100$
  • 输入中的所有值都是整数。

输入

输入数据从标准输入按以下格式给出:

$N$ $A$ $X$ $Y$

输出

打印出购买N颗卷心菜所需的钱数(整数)。


样例输入1

5 3 20 15

样例输出1

90

你需要为前3颗卷心菜各支付20日元,第4和第5颗各支付15日元。
因此,购买5颗卷心菜总共需要支付20+20+20+15+15=90日元。


样例输入2

10 10 100 1

样例输出2

1000

加入题单

算法标签: