알고리즘/구현
파이썬 | 백준 | 2217 | 로프
cha-n
2020. 11. 9. 17:46

solution
1. 내림차순
2. 15, 10의 경우 1. 15로프를 이용해 15의 중량 들어올리는 경우
2. 15로프, 10로프를 이용해 20의 중량을 10/10으로 들어올리거나
# 2217, 로프
import sys
import heapq
n = int(sys.stdin.readline())
heap = []
for _ in range(n):
w = int(sys.stdin.readline())
heapq.heappush(heap, (-w, w))
r = 1
max_ = 0
while heap:
max_ = max(max_, r * heapq.heappop(heap)[1])
r += 1
print(max_)
문제 출처 www.acmicpc.net/problem/2217
2217번: 로프
N(1≤N≤100,000)개의 로프가 있다. 이 로프를 이용하여 이런 저런 물체를 들어올릴 수 있다. 각각의 로프는 그 굵기나 길이가 다르기 때문에 들 수 있는 물체의 중량이 서로 다를 수도 있다. 하지만
www.acmicpc.net