Problem:
Score : 100 points

Problem Statement

You are parking at a parking lot. You can choose from the following two fee plans:

Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.

Plan 2: The fee will be B yen, regardless of the duration.

Find the minimum fee when you park for N hours.

Constraints

1≤N≤20

1≤A≤100

1≤B≤2000

All input values are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

When the minimum fee is x yen, print the value of x.

Sample Input 1

7 17 120

Sample Output 1

119

If you choose Plan 1, the fee will be 7×17=119 yen.

If you choose Plan 2, the fee will be 120 yen.

Thus, the minimum fee is 119 yen.

Sample Input 2

5 20 100

Sample Output 2

100

The fee might be the same in the two plans.

Sample Input 3

6 18 100

Sample Output 3

100

Solution in Ruby (2.3.3) (judge verdict: Wrong Answer)

lines = $stdin.read
array = lines.split("\n")
 
TIME = 10**5*2
#TIME = 300
 
N,C = array[0].split(" ").map(&:to_i)
 
cumsum = Array.new(C).map{Array.new(TIME,0)}
 
array[1..N+1].each do |rec|
  s,t,c  = rec.split(" ").map(&:to_i)
  s,t=s*2-1,t*2     # double
  s,t,c=s-1,t-1,c-1 # 0-indexed
  cumsum[c][s] += 1
  cumsum[c][t] -= 1
end
 
ans = Array.new(TIME,0)
cumsum.each do |sum|
  for i in 1...sum.length
    sum[i] += sum[i-1]
    ans[i] += sum[i]
  end
end
puts ans.max