File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed
Algorithm/ProgrammersCodingTest Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -3443,4 +3443,36 @@ def solution(s):
34433443 for j in range (i + 1 , len (s )+ 1 ):
34443444 if s [i :j ] == s [i :j ][::- 1 ]: answer = max (answer , len (s [i :j ]))
34453445
3446- return answer
3446+ return answer
3447+
3448+
3449+
3450+ # 카운트 다운(131129) - Lv.3
3451+ def solution (target ):
3452+ max_score = 100001
3453+ possible_score = [[50 , 1 ]]
3454+ dp = [[] for _ in range (max (target + 1 , 61 ))]
3455+
3456+ for i in range (1 , 21 ):
3457+ possible_score .append ([i , 1 ])
3458+ if i * 2 > 20 : possible_score .append ([i * 2 , 0 ])
3459+ if i * 3 > 20 and ((i * 3 ) % 2 != 0 or i * 3 > 40 ): possible_score .append ([i * 3 , 0 ])
3460+
3461+ for i in range (1 , 21 ):
3462+ dp [i ] = [1 , 1 ]
3463+ dp [i * 2 ] = [1 , 0 ]
3464+ dp [i * 3 ] = [1 , 0 ]
3465+
3466+ dp [50 ] = [1 , 1 ]
3467+
3468+ for i in range (1 , target + 1 ):
3469+ temp_arr = []
3470+
3471+ if len (dp [i ]) == 0 :
3472+ for p , is_sb in possible_score :
3473+ if i - p > 0 : temp_arr .append ([dp [i - p ][0 ] + 1 , dp [i - p ][1 ] + is_sb ])
3474+
3475+ temp_arr = sorted (temp_arr , key = lambda x : (x [0 ], - x [1 ]))
3476+ dp [i ] = temp_arr [0 ]
3477+
3478+ return dp [target ]
You can’t perform that action at this time.
0 commit comments