Search
Duplicate
๐Ÿฅˆ

ํ‡ด์‚ฌ

์ฃผ์ฐจ
๋ฌธ์ œ๋ฒˆํ˜ธ
14501
์–ธ์–ด
Python
ํ‹ฐ์–ด
์‹ค๋ฒ„
์œ ํ˜•
DP
์™„์ „ํƒ์ƒ‰
nj_Blog
O
nj_์ƒํƒœ
์™„๋ฃŒ
์ดํ•ด๋„
ํ’€์ด
์‚ฌ๋žŒ
์ดํ•ด๋„ 2
13 more properties

๋ฌธ์ œ๋งํฌ

https://www.acmicpc.net/problem/14501

์ฝ”๋“œ ์ œ์ถœ ๊ธฐ๋ก (๋ฉ”๋ชจ๋ฆฌ ๋ฐ ์‹œ๊ฐ„)

์ œ์ถœ ๋‚ ์งœ

@4/22/2021

๋ฉ”๋ชจ๋ฆฌ

121220 KB

์‹œ๊ฐ„

112 ms

๋ฉ”๋ชจ

โ€ข
์‚ผ์„ฑ sw ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ๊ธฐ์ถœ

๋ฌธ์ œํ’€์ด

Code

N = int(input()) time = [0 for _ in range(N)] pay = [0 for _ in range(N)] DP = [0 for _ in range(N+1)] for i in range(N): tmp = list(map(int, input().split())) time[i] = tmp[0] pay[i] = tmp[1] DP[N] = 0 for i in range(N-1, -1, -1): if (N-i) < time[i]: DP[i] = DP[i+1] else: DP[i] = max(pay[i] + DP[i+time[i]], DP[i+1]) print(DP[0])
Python
๋ณต์‚ฌ