Problem:


電子レンジ (Microwave)

問題

JOI 君は食事の準備のため，A ℃の肉を電子レンジで B ℃まで温めようとしている．
肉は温度が 0 ℃未満のとき凍っている．
また，温度が 0 ℃より高いとき凍っていない．
温度がちょうど 0 ℃のときの肉の状態は，凍っている場合と，凍っていない場合の両方があり得る．

JOI 君は，肉の加熱にかかる時間は以下のようになると仮定して，肉を温めるのにかかる時間を見積もることにした．

肉が凍っていて，その温度が 0 ℃より小さいとき： C 秒で 1 ℃温まる．

肉が凍っていて，その温度がちょうど 0 ℃のとき： D 秒で肉が解凍され，凍っていない状態になる．

肉が凍っていないとき： E 秒で 1 ℃温まる．

この見積もりにおいて，肉を B ℃にするのに何秒かかるかを求めよ．

入力

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

1 行目には，もともとの肉の温度 A が書かれている．

2 行目には，目的の温度 B が書かれている．

3 行目には，凍った肉を 1 ℃温めるのにかかる時間 C が書かれている．

4 行目には，凍った肉を解凍するのにかかる時間 D が書かれている．

5 行目には，凍っていない肉を 1 ℃温めるのにかかる時間 E が書かれている．

もともとの温度 A は -100 以上 100 以下，目的の温度 B は 1 以上 100 以下であり，A &ne; 0 および A < B を満たす．

温めるのにかかる時間 C, D, E はすべて 1 以上 100 以下である．

出力

肉を B ℃にするのにかかる秒数を 1 行で出力せよ．

入出力例

入力例 1

-10
20
5
10
3

出力例 1

   

120

入力例 2
  
  

35
92
31
50
11

出力例 2

627

入出力例 1 では，もともとの肉は -10 ℃で凍っている．かかる時間は以下のようになる．

-10 ℃から 0 ℃まで温めるのに 5 × 10 = 50 秒．

0 ℃の肉を解凍するのに 10 秒．

0 ℃から 20 ℃まで温めるのに 3 × 20 = 60 秒．

したがって，かかる時間の合計は 120 秒である．

入出力例 2 では，もともとの肉は凍っていない．したがって，肉を 35 ℃から 92 ℃まで温めるのにかかる時間は 627 秒である．

情報オリンピック日本委員会作 『第 16 回日本情報オリンピック JOI 2016/2017 予選競技課題』



Sample input:
-10
20
5
10
3


Sample output:
120

Submission status: Wrong Answer

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

t = 0

if A < 0:
    t += C * abs(A) + D

t += E * (B - A)

print(t)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
if a < 0:
    if b < 0:
        ans = (b-a)*c
    else:
        ans = abs(a)*c+d+b*e
else:
    ans = (b-a)*e
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8

A, B, C, D, E = [int(input()) for i in range(5)]

time = 0
if A < 0: time += (min(B, 0) - A)*C
if A*B <= 0: time += D
if B > 0: time += (B - max(A, 0))*E
print(time)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
time = 0
if a < 0 and b < 0:
    time += (b - a) * c
    print(time)
    sys.exit()
if b == 0:
    time += (-a) * c + d
    print(time)
    sys.exit()
if b > 0:
    if a < 0:
        time += (-a) * c + d + b * e
        print(time)
    else:
        time += (b - a) * e
        print(time)
        sys.exit()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
if a<0:
    print(-a*c+d+b*e)
else:
    print((b-a)*e)

Submission status: Accepted

Solution code:
s, ae= 0, [int(input()) for _ in range(5)]
f = True if ae[0]<0 else False
while ae[0]!= ae[1]:
    if ae[0]< 0:
        s, ae[0]= s+ae[2], ae[0]+1
    elif ae[0]== 0 and f:
        s, f= s+ae[3], False
    else:
        s, ae[0]= s+ae[4], ae[0]+1
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import time
s=time.time()
while time.time()-s<39.9:pass
i=input
a,b,c,d,e=map(int,[i(),i(),i(),i(),i()])
if a<0:print(c*-a+d+b*e)
else:print((b-a)*e)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

if a < 0:
  ans += abs(a)*c
  a = 0

if a == 0:
  ans += d

ans += (b-a)*e

print ans

Submission status: Accepted

Solution code:
def main():
    v = [int(input()) for _ in 5*[0]]
    ans = 0
    if v[0] < 0:
        ans += abs(v[0]) * v[2]
        v[0] = 0
    if v[0] == 0:
        ans += v[3]
    ans += abs(v[1]-v[0]) * v[4]
    print(ans)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
to,tt,tf,me,tn=[int(input())for i in range(5)]
if to<0:print(-to*tf+me+tt*tn)
else:print((tt-to)*tn)

Submission status: Accepted

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
time = 0

if A != B:
    if A < 0:
        time += C * (-A)
        time += D
        time += E * B
    if A == 0:
        time += D
        time += E * B
    if A > 0:
        time += E * (B - A)
elif A == B:
    time = B

print(time)

Submission status: Accepted

Solution code:
A, B, C, D, E = map(int, open(0).read().split())
if A < 0:
    if B > 0:
        print(-A*C+D+E*B)
    else:
        print((B-A)*C)
else:
    print((B-A)*E)

Submission status: Accepted

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

if a < 0:
    if b <= 0:
        print((b - a) * c)
    else:
        print(- a * c + d + b * e)
else:
    print((b - a) * e)

Submission status: Accepted

Solution code:
def frozen(A, t):
    if A >= B or A >= 0: return A, t
    return frozen(A + 1, t + C)

def normal_temperature(A, t):
    if A >= B: return A, t
    return normal_temperature(A + 1, t + E)

t = 0
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
# 温度が０℃より低い時、温度を１℃上げるのにかかる時間
if A < 0:
    A, t = frozen(A, t)
# 解凍にかかる時間
if A == 0 and A < B:
    t+=D
# 温度が０℃より高い時、温度を１℃上げるのにかかる時間
if A >= 0:
    A, t = normal_temperature(A, t)

print(t)

Submission status: Accepted

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

t = 0

if A < 0:
    t += C * abs(A) + D

t += E * (B - max(0, A))

print(t)

Submission status: Accepted

Solution code:
# AOJ 0630: Microwave
# Python3 2018.7.2 bal4u

a, b, c, d, e = [int(input()) for i in range(5)]
if   a < 0 and b < 0: ans = c*(b-a)
elif a > 0 and b > 0: ans = e*(b-a)
else:                 ans = c*(-a)+d+e*b
print(ans)

Submission status: Accepted

Solution code:
s=[int(input()) for _ in range(5)]
if s[0]<0:
    print(-s[0]*s[2]+s[3]+s[1]*s[4])
else:
    print((s[1]-s[0])*s[4])

Submission status: Accepted

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

ans = 0

while A < B:
    flag=True
    if A<0:
        ans += C*(abs(A))
        A+=abs(A)
        flag=False
    elif A==0:
        ans+=D
        flag=True
    if flag:
        ans += E*(B-A)
        A+=(B-A)
print(ans)

Submission status: Accepted

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
time=0
if a<0:
    a=(-1)*a
    time=a*c+d+b*e
elif a==0:
    time=d+b*e
else:
    b=b-a
    time=b*e
print(time)

Submission status: Accepted

Solution code:
mylist=[]

for i in range(5):
    a=int(input())
    mylist.append(a)

if mylist[0]<0:
    print(mylist[0]*mylist[2]*(-1)+mylist[3]+mylist[1]*mylist[4])
else:
    print((mylist[1]-mylist[0])*mylist[4])

Submission status: Accepted

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

if l[0] < 0:
    print((0 - l[0]) * l[2] + l[3] + l[1] * l[4])

elif l[0] == 0:
     print(l[3] + l[1] * l[4])

else:
    print((l[1]-l[0]) * l[4])

Submission status: Accepted

Solution code:
a, b, c, d, e =[int(input())for i in range(5)]

if a < 0 and b < 0:
    ans = c*(b-a)
elif a > 0 and b > 0:
    ans = e*(b-a)
else:
    ans = c*(-a)+d+e*b
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if a <= 0:
    t = -a*c
    t = t + d
    a = 0

print(t + (b-a)*e)

Submission status: Accepted

Solution code:
a, b, c, d, e = [int(input()) for _ in range(5)]
# print(e)
t = 0
if a < 0:
	t = -a * c
	t = t + d
	t = t + b * e
else:
	t = t + (b - a) * e
print(t)

Submission status: Accepted

Solution code:
temp_a, temp_b, temp_c, temp_d, temp_e = [int(input()) for _ in range(5)]

frozen = temp_c * abs(temp_a) 
not_frozen = temp_e * temp_b + temp_d

if temp_a <= 0:
    print(frozen + not_frozen)
else:
    print((temp_b - temp_a) * temp_e)

Submission status: Accepted

Solution code:
int_list = []
for num in range(5):
    inta = int(input())
    int_list.append(inta)
if int_list[0] < 0:
    num1 = int_list[0] * -1
    num2 = num1 * int_list[2]
    num2 += int_list[3]
    num3 = int_list[4] * int_list[1]
    num2 += num3
    print(num2)
elif int_list[0] > 0:
    num1 = int_list[1] - int_list[0]
    num2 = num1 * int_list[4]
    print(num2)

Submission status: Accepted

Solution code:
import sys
import math
time=0
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
if(a<0):
    a_temperature=abs(a)
    time=a_temperature*c
    time=time+d
    time=time+b*e
    
if(a>=0):
    if(a==0):
        time=time+d
    time=time+(b-a)*e
print(time)

Submission status: Accepted

Solution code:
# 入力
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
result=0

# 処理
# 肉が凍っていて，その温度が 0 ℃より小さいとき
if A<0:
    # C 秒で 1 ℃温まる (0秒含む）
    result+=C*-(A)
    # 肉が凍っていて，その温度がちょうど 0 ℃のとき
    result+=D

    result+=B*E
# 肉が凍っていないとき
elif A==0:
    result=+E
    result+=B*E
else:
    result+=(B-A)*E



print(result)

Submission status: Accepted

Solution code:
x = [int(input()) for s in range(5)]
if x[0] > 0:
    print(int(x[4]*(x[1]-x[0])))
else:
    t = abs(x[0])*x[2]+x[3]+x[1]*x[4]
    print(t)

Submission status: Accepted

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

t += (b - max(a, 0)) * e

print(t)

Submission status: Accepted

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

if a < 0:
    print(abs(a) * c + d + b * e)
elif a == 0:
    print(d + b * e)
else:
    print((b-a) * e)

Submission status: Accepted

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

if A <= 0:
    ans = -A*C+D+B*E
    print(ans)

else:
    print((B-A)*E)

Submission status: Accepted

Solution code:
a, b, c, d, e = [int(input())for i in range(5)]
t = 0
b += (a<0)
while a!=b:
    if a<0: t+=c
    elif a==0: t+=d
    else: t+=e
    a+=1
print(t)

Submission status: Accepted

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

if a[0] <= 0:
    time = -a[0]*a[2] + a[3] + a[1]*a[4]
else:
    time = (a[1] - a[0])*a[4]

print(time)

Submission status: Accepted

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

if A>0:
    print((B-A)*E)
else:
    print((-1*A)*C+D+B*E)

Submission status: Accepted

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

if a < 0:
    print(-a*c+d+b*e)
else:
    print((b-a)*e)

Submission status: Accepted

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

if A > 0:
    print(E * (B - A))
if A == 0:
    print(D + E * B)
if A < 0:
    print(C * abs(A) + D + E * B)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Microwave
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0630

"""
import sys


def solve(a, b, c, d, e):
    ans = 0
    while a < b:
        if a < 0:
            a += 1
            ans += c
        elif a == 0:
            a += 1
            ans += (d + e)
        else:
            a += 1
            ans += e
    return ans


def main(args):
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())
    ans = solve(a, b, c, d, e)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
time=(b-a)*e
if a<0:
    time=(-a)*c+d+b*e
print(time)

Submission status: Accepted

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

if A > 0:
  print((B - A) * E)
if A < 0:
  print((-A * C)+ D + (B * E))

Submission status: Accepted

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
total_time = 0
if A > 0:
    total_time = (B - A) * E
elif A == 0:
    total_time += D
    total_time += B * E
else:
    total_time += -A * C
    total_time += D
    total_time += B *E

print(total_time)

Submission status: Accepted

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

min=0

if a<0 :
    aa=-1*a
    min+=aa*c+d+b*e
elif a==0 :
    min+=c+b*e
else :
    min+=(b-a)*e

print(min)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
a,b,c,d,e=map(int,sys.stdin.read().split())
if a<=0:
	print(-a*c+d+b*e)
else:
	print((b-a)*e)

Submission status: Accepted

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
print(-a*c+d+b*e if a<0 else (b-a)*e)

Submission status: Accepted

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

if a < 0:
    ans = -a * c + d + b * e
elif a == 0:
    ans = d + b * e
else:
    ans = (b - a) * e

print(ans)

Submission status: Accepted

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
ans=0
if(a<0):
  ans+=d
  ans+=c*(-a)
  a=0
ans+=(b-a)*e
print(ans)

Submission status: Accepted

Solution code:
tem = []
for i in range(5):
    tem.append(int(input()))
    
t = 0
if (tem[0]<0):
    t += (0-tem[0])*(tem[2])
    t += tem[3]
    t += tem[1]*(tem[4])
elif (tem[0]>0):
    t += (tem[1] - tem[0])*(tem[4])
print(t)

Submission status: Accepted

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

if list1[0]<0:
    ans=(0-list1[0])*list1[2]+list1[3]+list1[1]*list1[4]
else:
    ans=(list1[1]-list1[0])*list1[4]
print(ans)

Submission status: Runtime Error

Solution code:
for i in range(5):
  a=int(input())
  b=int(input())
  c=int(input())
  d=int(input())
  e=int(input())
  if a<0:
    x=abs(a)*c+d+b*e
    print(x)
  else:
    y=(b-a)*e
    print(y)

Submission status: Runtime Error

Solution code:
for i in range(5):
  a=int(input())
  b=int(input())
  c=int(input())
  d=int(input())
  e=int(input())
  if a<0:
    x=abs(a)*c+d+b*e
    print(x)
  elif a>=0:
    y=(b-a)*e
    print(y)
  else:
    pass

Submission status: Runtime Error

Solution code:
for i in range(5):
  a=int(input())
  b=int(input())
  c=int(input())
  d=int(input())
  e=int(input())
  if a<0 and a<b:
    x=abs(a)*c+d+b*e
    print(x)
  elif a>0 and a<b:
    y=(b-a)*e
    print(y)
  else:
    pass

Submission status: Runtime Error

Solution code:
for i in range(5):
  a=int(input())
  b=int(input())
  c=int(input())
  d=int(input())
  e=int(input())
  if a<0 and a<b:
    x=abs(a)*c+d+b*e
    print(x)
  elif a>0 and a<b:
    y=(b-a)*e
    print(y)
  else:
    break

Submission status: Runtime Error

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
>>> import time
>>> time.sleep(1)
if(a>=0):
    print ((b-a)*e);
else:
    print(a*-c+d+b*e);

Submission status: Runtime Error

Solution code:
import time
s=time.time()
while time.time()-s<39.99:pass
i=input;a,b,c,d,e=map(int,[i(),i(),i(),i(),i()])
print(c*-a+d+b*e)if a<0 else print((b-a)*e)

Submission status: Runtime Error

Solution code:
import time
s=time.time()
while time.time()-s<39.99:pass
i=input
a,b,c,d,e=map(int,[i(),i(),i(),i(),i()])
print(c*-a+d+b*e)if a<0 else print((b-a)*e)

Submission status: Runtime Error

Solution code:
import time
s=time.time()
while time.time()-s<39.99:pass
i=input;a,b,c,d,e=map(int,[i(),i(),i(),i(),i()])
if a<0:print(c*-a+d+b*e)
else:print((b-a)*e)

Submission status: Runtime Error

Solution code:
import time
s=time.time()
while time.time()-s<39.99:pass
i=input
a,b,c,d,e=map(int,[i(),i(),i(),i(),i()])
if a<0:print(c*-a+d+b*e)
else:print((b-a)*e)

Submission status: Runtime Error

Solution code:
A=?????¨?????¨??????????????? = int(input())
B=??????????????? = int(input())
C=?????£????????????????????????????????????????????? = int(input())
D=?????£??????????§£?????????????????????????????? = int(input())
E=?????£?????????????????????????????????????????????????????? = int(input())

if A>0:
	print((B-A)*E)
else:
	print(C*abs(A)+D+E*B)