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로 초기화 하여 작은 수 부터 더했을 때 특정 데이터 값 보다 작다면 만들 수 없는 수의 최솟값이다.
'Algorithm > Problems' 카테고리의 다른 글
99클럽 코테 스터디 11일차 TIL + 이분탐색 (0) | 2025.04.14 |
---|---|
99클럽 코테 스터디 10일차 TIL + 그리디 (0) | 2025.04.12 |
99클럽 코테 스터디 8일차 TIL + 문자열 (0) | 2025.04.09 |
99클럽 코테 스터디 7일차 TIL + 스택 (0) | 2025.04.08 |
99클럽 코테 스터디 6일차 TIL + DFS (0) | 2025.04.07 |