Problem:


水道料金 (Water Rate)

 問題

JOI 君が住んでいる地域には水道会社が X 社と Y 社の 2 つある．2 つの会社の 1 ヶ月の水道料金は，1 ヶ月の水道の使用量に応じて次のように決まる．

X 社： 1 リットル あたり A 円かかる．

Y 社： 基本料金は B 円である．使用量が C リットル以下ならば，料金は基本料金 B 円のみがかかる．使用量が C リットルを超えると基本料金 B 円に加えて追加料金がかかる．追加料金は使用量が C リットルを 1 リットル超えるごとに D 円である．

JOI 君の家では 1 ヶ月の水道の使用量が P リットルである．

水道料金ができるだけ安くなるように水道会社を選ぶとき，JOI 君の家の 1 ヶ月の水道料金を求めよ．

入力

入力は 5 行からなり，1 行に 1 つずつ整数が書かれている．

1 行目には X 社の 1 リットルあたりの料金 A が書かれている．

2 行目には Y 社の基本料金 B が書かれている．

3 行目には Y 社の料金が基本料金のみになる使用量の上限 C が書かれている．

4 行目には Y 社の 1 リットルあたりの追加料金 D が書かれている．

5 行目には JOI 君の家の 1 ヶ月の水道の使用量 P が書かれている．

書かれている整数 A, B, C, D, P はすべて 1 以上 10000 以下である．

出力

JOI 君の家の 1 ヶ月の水道料金を表す整数を 1 行で出力せよ．

入出力例

入力例 1

9
100
20
3
10

出力例 1

90

入力例 2

8
300
100
10
250

出力例 2

1800

入出力例 1 では，JOI 君の家の 1 ヶ月の水道の使用量は 10 リットルである．

X 社の水道料金は 9 &times; 10 = 90 円である．

JOI 君の家の 1 ヶ月の水道の使用量は 20 リットル以下なので，Y 社の水道料金は基本料金の 100 円である．

JOI 君の家は水道料金がより安い X 社を選ぶ．そのときの JOI 君の家の 1 ヶ月の水道料金は 90 円である．

入出力例 2 では，JOI 君の家の 1 ヶ月の水道の使用量は 250 リットルである．

X 社の水道料金は 8 &times; 250 = 2000 円である．

JOI 君の家の 1 ヶ月の水道の使用量は 100 リットル以上で，超過量は 250 - 100 = 150 リットルである．よって，Y 社の水道料金は基本料金の 300 円に加えて 10 &times; 150 = 1500 円の追加料金がかかり，合計の水道料金は 300 + 1500 = 1800 円である．

JOI 君の家は水道料金がより安い Y 社を選ぶ．そのときの JOI 君の家の 1 ヶ月の水道料金は 1800 円である．

問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。



Sample input:
9
100
20
3
10


Sample output:
90

Submission status: Wrong Answer

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())
print(min(P*A, B+abs(C-P)*D))

Submission status: Wrong Answer

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())
print(min(P*A, B if C <= P else B+(P-C)*D))

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
p = int(input())
costx = a * p
costy = b if p <= c else b + (p - c) * d
print(min(costx, costy))

Submission status: Accepted

Solution code:
# coding: utf-8

A, B, C, D, P = [int(input()) for i in range(5)]
cost = B + max(0, P - C)*D
cost = A*P if A*P < cost else cost
print(cost)

Submission status: Accepted

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
p=int(input())
x=p*a
if p<=c:
  if x<=b:
    print(x)
  else:
    print(b)
else:
  z=b+(p-c)*d
  if x<=z:
    print(x)
  else:
    print(z)

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
p = int(input())
ans = p*a
ans = min(ans, b+max(p-c,0)*d)
print(ans)

Submission status: Accepted

Solution code:
A, B, C, D, P = [int(input()) for i in range(5)]
print(min(A * P, B + max(0, (P - C) * D)))

Submission status: Accepted

Solution code:
l = [input() for _ in range(5)]
print min(l[0]*l[4], l[1] if l[2]>=l[4] else l[1]+(l[4]-l[2])*l[3])

Submission status: Accepted

Solution code:
a,b,c,d,e = [input() for _ in range(5)]
print min(a*e, b if c>=e else b+(e-c)*d)

Submission status: Accepted

Solution code:
import sys
                                       
lst = []
for i in sys.stdin:
    lst.append(int(i))
                                                                                            
a = lst[0]*lst[4]
                                            
b = lst[1]
if lst[4] > lst[2]:
    b = b + lst[3]*(lst[4]-lst[2])

if a > b:
    print b
else:
    print a
sys.exit(0)

Submission status: Accepted

Solution code:
a=[]

for i in range(4):
    x=int(input())
    a.append(x)

p=int(input())
r1=p*a[0]
r2=0

if(p>a[2]):
    r2=a[1]+(p-a[2])*a[3]
else:
    r2=a[1]

print(min(r1,r2))

Submission status: Accepted

Solution code:
a = []
for i in range(5):
  a.append(int(input()))

x = a[0] * a[4]
y = a[1] + max(a[4] - a[2], 0) * a[3]

print(min(x, y))

Submission status: Accepted

Solution code:
A = input()
B = input()
C = input()
D = input()
P = input()
print min(P*A, B+max(P-C,0)*D)

Submission status: Accepted

Solution code:
a,b,c,d,e=[int(input()) for _ in range(5)]
print(min(a*e,b+max(e-c,0)*d))

Submission status: Accepted

Solution code:
A, B, C, D, P= int(input()),int(input()),int(input()),int(input()),int(input())
print(min(A*P, B if P<=C else B+(P-C)*D))

Submission status: Accepted

Solution code:
A=int(input())
B=int(input())
C=int(input())
D=int(input())
P=int(input())

X=A*P

if P<=C:
    Y=B
else:
    Y=B+(P-C)*D

if X<=Y:
    print(X)
else:
    print(Y)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

x_per_liter = int(input())
y_base_cost = int(input())
y_limit = int(input())
y_addition = int(input())
liter = int(input())

x_cost = x_per_liter * liter
if liter <= y_limit:
    y_cost = y_base_cost
else:
    y_cost = y_base_cost + y_addition * (liter - y_limit)

print(min(x_cost, y_cost))

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
p = int(input())

x_price = p*a
y_price = b 
if p>c:
    y_price += d*(p-c)

if x_price<y_price:
    print(x_price)
else:
    print(y_price)

Submission status: Accepted

Solution code:
A,B,C,D,P=[int(input())for i in range(5)]
print(min(A*P,B+((P-C if P>C else 0)*D)))

Submission status: Accepted

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())
print(min(P*A, B if C >= P else B+(P-C)*D))

Submission status: Accepted

Solution code:
a,b,c,d,p=[int(input())for i in range(5)]
print(min(p*a,b+d*(max(c,p)-c)))

Submission status: Accepted

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())

X_price = 0
X_price = A * P

Y_price = 0
Y_price += B

if P > C:
    Y_price += (P - C) * D

print(min(Y_price, X_price))

Submission status: Accepted

Solution code:
A, B, C, D, P = [int(input()) for i in range(5)]
print(min(A*P, B+max(0, P-C)*D))

Submission status: Accepted

Solution code:
a, b, c, d, e = int(input()), int(input()), int(input()), int(input()), int(input())
print(min(a * e, b + max(e - c, 0) * d))

Submission status: Accepted

Solution code:
# AOJ 0608: Water Rate
# Python3 2018.7.2 bal4u

import sys
from sys import stdin
input = stdin.readline

a, b, c, d, p = [int(input()) for i in range(5)]
pa, pb = p*a, b
if p > c: pb += (p-c)*d
print(min(pa, pb))

Submission status: Accepted

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
p=int(input())
x=a*p
y=0
if p>c:
    y=b+(p-c)*d
else:
    y=b
if x>y:
    print(y)
else:
    print(x)

Submission status: Accepted

Solution code:
l = [int(input()) for i in range(5)]
x = l[0] * l[4]

if l[4] >= l[2]:
    y = l[1] + l[3] * (l[4]-l[2])
else:
    y = l[1]

print(min(x,y))

Submission status: Accepted

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())

X = P * A
Y = B
if P > C:
	Y = Y + D * (P - C)

if X > Y:
	print(int(Y))
else:
	print(int(X))

Submission status: Accepted

Solution code:
num_list = [] #空リスト作成
for _ in range(5): #5回繰り返す
    num_list.append(int(input())) #標準入力をしてそのままリストに格納
num1 = num_list[0] * num_list[4] #X社の料金計算
if num_list[2] < num_list[4]: #Y社の制限を超えるか
    num2 = num_list[4] - num_list[2] #何L超えるか
    num2 = num2 * num_list[3] + num_list[1] #超えた時のY社の料金計算
else:num2 = num_list[1] #超えなかった時のY社の料金計算
print(min(num1,num2)) #2社の料金が安い方を出力

Submission status: Accepted

Solution code:
import sys
import math
a=int(input())
b=int(input())
c=int(input())
d=int(input())
p=int(input())
x=a*p
y=b
if(c<p):
    ryo=p-c
    y=y+(ryo*d)
if(x<=y):
    chap=x
else:
    chap=y
print(chap)

Submission status: Accepted

Solution code:
A=int(input())
B=int(input())
C=int(input())
D=int(input())
P=int(input())
print(min(A*P,B+(D*(max(P-C,0)))))

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
p = int(input())

x = a * p
y = b + max((p-c) * d, 0)

print(min(x, y))

Submission status: Accepted

Solution code:
A, B, C, D, P = [int(input()) for _ in range(5)]

charge_x = A * P
charge_y = B + (P-C) * D if P >= C else B

print(min(charge_x, charge_y))

Submission status: Accepted

Solution code:
A=int(input())
B=int(input())
C=int(input())
D=int(input())
P=int(input())
X=P*A
if P<C:
    Y=B
else:
    Y=(P-C)*D+B
print(min(X,Y))

Submission status: Accepted

Solution code:
#A問題
A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())

p1 = P*A
p2 = 0
if P > C:
    p2 = B + (P-C)*D
else:
    p2 = B
    
print(min(p1,p2))

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
p = int(input())

x = a*p
if c >= p:
    y = b
else:
    y = b + (p-c)*d

print(min([x, y]))

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
p = int(input())

x = a * p
y = b + max(0,p-c)*d
print(min(x,y))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())

X = A * P
if P <= C:
    Y = B
else:
    Y = B + D * (P - C)
print(min(X,Y))

Submission status: Accepted

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
p=int(input())
x=a*p
y=b
if p>c:
    y+=(p-c)*d
print(min(x,y))

Submission status: Accepted

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())

print(min(P * A, B if P <= C else (B + (P - C) * D)))

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

x = a * e
if e < c:
  y = b
else:
  y = b + d *(e-c)

p=[x,y]
print(min(p))

Submission status: Accepted

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
p=int(input())

x=a*p

if c>=p:
    y=b
else:
    y=b+(p-c)*d

print(min(x,y))

Submission status: Accepted

Solution code:
def smaller(x, y):
	if x < y: return x
	else: return y

A = int(raw_input())
B = int(raw_input())
C = int(raw_input())
D = int(raw_input())
P = int(raw_input())

X = P*A
Y = B
if C < P:
	Y += (P-C)*D
print smaller(X, Y)

Submission status: Accepted

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
print(min(a*e,[b,b+(e-c)*d][c<e]))

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
p = int(input())
x = p*a
if p>=c:
    y = b+(p-c)*d
else:
    y = b
if x >= y:
    print(y)
else:
    print(x)

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
p = int(input())

x = a * p
if p <= c:
    y = b
else:
    y = b + (p-c) * d

print(min(x, y))

Submission status: Runtime Error

Solution code:
# solve problem
def solve(n, m, targets, games):
    counter = [0 for i in range(n+1)]

    for i in range(m):
        for j in range(n):
            if games[i][j] == targets[i]:
                counter[j+1] += 1
            else:
                counter[targets[i]] += 1

    return counter


# main function
if __name__ == '__main__':
    n = int(input())
    m = int(input())
    tmp_targets = input().split()

    targets = []
    for i in range(m):
        targets.append(int(tmp_targets[i]))

    games = [[0 for i in range(n)] for j in range(m)]
    tmp_games = []
    for i in range(m):
        tmp_games = input().split()
        for j in range(n):
            games[i][j] = int(tmp_games[j])

    results = solve(n, m, targets, games)
    for i in range(1, n+1, 1):
        print(results[i])

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())
print(min(P*A, B if C <= P else B+(P-C)*D)