Skip to content

Commit

Permalink
Merge pull request #172 from AlgoLeadMe/9-H0ngJu
Browse files Browse the repository at this point in the history
9-H0ngJu
  • Loading branch information
MunbinLee authored May 3, 2024
2 parents 7c8ec30 + bc1f839 commit 55dc5e8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
21 changes: 21 additions & 0 deletions H0ngJu/DP/RGB거리 2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import sys

def input(): return sys.stdin.readline().rstrip()

N = int(input())
INF = 1000*1000+1

house = [[int(x) for x in input().split()] for _ in range(N)]
cost = INF

for first_house in range(3):
dp = [[INF] * 3 for _ in range(N)]
dp[0][first_house] = house[0][first_house]
for i in range(1, N):
dp[i][0] = min(dp[i-1][1], dp[i-1][2]) + house[i][0]
dp[i][1] = min(dp[i-1][0], dp[i-1][2]) + house[i][1]
dp[i][2] = min(dp[i-1][0], dp[i-1][1]) + house[i][2]
dp[N-1][first_house] = INF
cost = min(cost, min(dp[N-1]))

print(cost)
5 changes: 3 additions & 2 deletions H0ngJu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
| 3μ°¨μ‹œ | 2024.03.10 | νž™ | [N번째 큰 수](https://www.acmicpc.net/problem/2075) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/156 |
| 4μ°¨μ‹œ | 2024.03.13 | νž™ | [λ¬Έμ œμ§‘](https://www.acmicpc.net/problem/1766) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/158 |
| 5μ°¨μ‹œ | 2024.03.16 | κ΅¬ν˜„ | [μš”μ„Έν‘ΈμŠ€ 문제](https://www.acmicpc.net/problem/1158) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/161 |
| 6μ°¨μ‹œ | 2024.03.19 | μŠ€νƒ | [였큰수](https://www.acmicpc.net/problem/17298) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/164 |
| 7μ°¨μ‹œ | 2024.03.22 | DP | [1,2,3 λ”ν•˜κΈ°](https://www.acmicpc.net/problem/9095) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/166 |
| 6μ°¨μ‹œ | 2024.03.19 | μŠ€νƒ | [였큰수](https://www.acmicpc.net/problem/17298) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/164 |
| 7μ°¨μ‹œ | 2024.03.22 | DP | [1,2,3 λ”ν•˜κΈ°](https://www.acmicpc.net/problem/9095) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/166 |
| 8μ°¨μ‹œ | 2024.03.16 | DP | [μ‰¬μš΄ 계단 수](https://www.acmicpc.net/problem/10844) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/170 |
| 9μ°¨μ‹œ | 2024.03.22 | DP | [RGB거리 2](https://www.acmicpc.net/problem/17404) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/172 |

---
File renamed without changes.

0 comments on commit 55dc5e8

Please sign in to comment.