728x90
https://www.acmicpc.net/group/practice/view/17857/2
로그인
www.acmicpc.net

import sys
input = sys.stdin.readline
N = int(input())
dp = [5001] * (N + 5)
dp[3] = dp[5] = 1
for i in range(6, N + 1):
dp[i] = min(dp[i - 3], dp[i - 5]) + 1
if dp[N] >= 5001:
print("-1")
else:
print(dp[N])
728x90
'Study > Coding Test' 카테고리의 다른 글
[백준] 17070 - 파이프 옮기기1 Python (0) | 2023.05.23 |
---|---|
[백준] 10815 - 숫자 카드 Python (0) | 2023.05.23 |
[백준] 2839 - 설탕 배달 Python (0) | 2023.05.23 |
[백준] 11000 - 강의실 배정 Python (0) | 2023.05.22 |
[백준] 2468 - 안전 영역 Python (0) | 2023.05.22 |