Algorithm
[백준 1092] 배
moguogu
2024. 9. 17. 16:12
문제
https://www.acmicpc.net/problem/1092
코드
import sys
N = int(input())
weight = list(map(int, input().split()))
M = int(input())
box = list(map(int, input().split()))
weight.sort(reverse=True)
box.sort(reverse=True)
if weight[0] < box[0]: #상자의 제일 무거운게 크레인 최대값 보다 크면 불가능
print(-1)
exit()
time = 0
i, j = 0, 0
while j < len(box):
time += 1
for c in weight:
if c >= box[j]: #현재 크레인을 쓸 수 있음
box.pop(j)
else: #현재 크레인을 쓸 수 없음 -> 다시 제일 무거운 크레인 부터 사용
break