Algorithm/Problems
99클럽 코테 스터디 9일차 TIL + 그리디
공부좀하시졍
2025. 4. 10. 22:19
https://www.acmicpc.net/problem/2437
# 2437 저울
import sys
input = sys.stdin.readline
n = int(input())
weights = list(map(int, input().split()))
weights.sort()
target = 1
for w in weights:
if target < w:
break
target += w
print(target)
- 입력 받은 무게 추 리스트를 오름차순으로 정렬
- target 변수를 1로 초기화 하여 작은 수 부터 더했을 때 특정 데이터 값 보다 작다면 만들 수 없는 수의 최솟값이다.