SWEA 1284. 수도 요금 경쟁 파이썬

Seomingi·2022년 9월 10일
0

단순 수학만 알면 풀수 있었다

n = int(input())

for i in range(1,n+1):
  p,q,r,s,w = map(int,input().split())
  a = p*w
  if r<w:
    b = (w-r)*s+q
  elif r>w:
    b = q

  if a<b:
    print('#{} {}'.format(i,a))
  elif a>b:
    print('#{} {}'.format(i,b))
profile
One thing after another

0개의 댓글