-
[9414] 프로그래밍 대회 전용 부지 (Python)[Python] 알고리즘/Silver 2021. 10. 27. 13:48
[문제]
https://www.acmicpc.net/problem/9414
알고리즘 분류는 수학, 정렬, 사칙연산 입니다.
땅값은 매년 오르므로, 땅을 최소의 가격으로 구매하기 위해선 비싼 땅을 먼저 구매해야 합니다.
돈이 부족한 경우도 조건을 걸어주어야 합니다.
[코드]
import sys T = int(sys.stdin.readline()) for i in range(T): li = list() res = 0 money = 5 * (10 ** 6) while True: ground = int(sys.stdin.readline()) if ground == 0: break li.append(ground) li.sort(reverse=True) for j in range(len(li)): res += 2 * (li[j] ** (j + 1)) if money < res: print("Too expensive") else: print(res)
'[Python] 알고리즘 > Silver' 카테고리의 다른 글
[5648] 역원소 정렬 (Python) (0) 2021.11.02 [1935] 후위 표기식2 (Python) (0) 2021.11.01 [11478] 서로 다른 부분 문자열의 개수 (Python) (0) 2021.10.31 [10815] 숫자 카드 (Python) (0) 2021.10.29 [9536] 여우는 어떻게 울지? (Python) (0) 2021.10.28