diff --git "a/tgyuuAn/DP/\354\202\260 \353\252\250\354\226\221 \355\203\200\354\235\274\353\247\201.py" "b/tgyuuAn/DP/\354\202\260 \353\252\250\354\226\221 \355\203\200\354\235\274\353\247\201.py" new file mode 100644 index 0000000..cd2881b --- /dev/null +++ "b/tgyuuAn/DP/\354\202\260 \353\252\250\354\226\221 \355\203\200\354\235\274\353\247\201.py" @@ -0,0 +1,19 @@ +def solution(n, tops): + top = set() + DIV = 10_007 + + count = 0 + for idx, element in enumerate(tops): + if element==1: + count += 1 + top.add(2*(idx+1)+count) + + DP = [0 for _ in range((n*2)+1+count+1)] + DP[1] = 1 + DP[2] = 2 + + for now_idx in range(3,len(DP)): + if (now_idx-1) in top: DP[now_idx] = (DP[now_idx-3] % DIV) + (DP[now_idx-1] % DIV) % DIV + else: DP[now_idx] = (DP[now_idx-2] % DIV) + (DP[now_idx-1] % DIV) % DIV + + return DP[-1] % DIV \ No newline at end of file diff --git a/tgyuuAn/README.md b/tgyuuAn/README.md index aea5b0d..49b7ac5 100644 --- a/tgyuuAn/README.md +++ b/tgyuuAn/README.md @@ -79,4 +79,5 @@ | 70차시 | 2024.08.16 | 스택 | 탑 보기 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/232 | 71차시 | 2024.08.20 | 다익스트라 | 다익스트라 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/235 | 72차시 | 2024.08.23 | DFS + 트리 | 등산 마니아 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/238 +| 75차시 | 2024.09.02 | DP | 산 모양 타일링 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/243 ---