From e004354f8db419924ba68ccfd08216cada3abce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=84=9D=7CMinseok=20Kim?= Date: Sat, 16 Mar 2024 20:23:37 +0900 Subject: [PATCH 1/4] =?UTF-8?q?17=EC=B0=A8=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=EC=84=A0=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...65\254\352\260\204-\353\202\230\353\210\204\352\270\260.py" | 0 alstjr7437/README.md | 3 ++- "alstjr7437/\354\240\225\353\240\254/tempCodeRunnerFile.py" | 3 --- 3 files changed, 2 insertions(+), 4 deletions(-) create mode 100644 "alstjr7437/DP/\352\265\254\352\260\204-\353\202\230\353\210\204\352\270\260.py" delete mode 100644 "alstjr7437/\354\240\225\353\240\254/tempCodeRunnerFile.py" diff --git "a/alstjr7437/DP/\352\265\254\352\260\204-\353\202\230\353\210\204\352\270\260.py" "b/alstjr7437/DP/\352\265\254\352\260\204-\353\202\230\353\210\204\352\270\260.py" new file mode 100644 index 0000000..e69de29 diff --git a/alstjr7437/README.md b/alstjr7437/README.md index 4b3dfca..a9ac7f8 100644 --- a/alstjr7437/README.md +++ b/alstjr7437/README.md @@ -17,4 +17,5 @@ | 13차시 | 2024.02.29 | DP | 쉬운 계단 수 | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/42 | | 14차시 | 2024.03.03 | 브루트포스 | 마인크래프트 | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/48 | | 15차시 | 2024.03.09 | 우선순위 큐 | 파일 합치기3 | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/53 | -| 16차시 | 2024.03.13 | 정렬 | 선 긋기 | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/57 | \ No newline at end of file +| 16차시 | 2024.03.13 | 정렬 | 선 긋기 | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/57 | +| 17차시 | 2024.03.16 | DP | 구간 나누기 | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/61 | \ No newline at end of file diff --git "a/alstjr7437/\354\240\225\353\240\254/tempCodeRunnerFile.py" "b/alstjr7437/\354\240\225\353\240\254/tempCodeRunnerFile.py" deleted file mode 100644 index 01e1add..0000000 --- "a/alstjr7437/\354\240\225\353\240\254/tempCodeRunnerFile.py" +++ /dev/null @@ -1,3 +0,0 @@ - -# dohwaji[i][0] += 1000000000 -# dohwaji[i][1] += 1000000000 \ No newline at end of file From 12c7b579a9ba4ee58dc244b7d00207d834efdbe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=84=9D=7CMinseok=20Kim?= Date: Tue, 19 Mar 2024 13:11:35 +0900 Subject: [PATCH 2/4] =?UTF-8?q?Update=20=EA=B5=AC=EA=B0=84-=EB=82=98?= =?UTF-8?q?=EB=88=84=EA=B8=B0.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4-\353\202\230\353\210\204\352\270\260.py" | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git "a/alstjr7437/DP/\352\265\254\352\260\204-\353\202\230\353\210\204\352\270\260.py" "b/alstjr7437/DP/\352\265\254\352\260\204-\353\202\230\353\210\204\352\270\260.py" index e69de29..6c56569 100644 --- "a/alstjr7437/DP/\352\265\254\352\260\204-\353\202\230\353\210\204\352\270\260.py" +++ "b/alstjr7437/DP/\352\265\254\352\260\204-\353\202\230\353\210\204\352\270\260.py" @@ -0,0 +1,21 @@ +# n, m = map(int,input()) + +# num = [ i for i in range(n): int(input())] + +# dp = [[-1e9] * m for _ in range(n+1)] +# for i in range(n): + +import sys +input = sys.stdin.readline + +n, m = map(int, input().split()) +dp1 = [[0]+[-1e9]*m for i in range(n+1)] +dp2 = [[0]+[-1e9]*m for i in range(n+1)] +num = [int(input()) for i in range(n) ] + +for i in range(1, n+1): + for j in range(1, min(m, (i+1)//2)+1): + dp2[i][j]=max(dp1[i-1][j], dp2[i-1][j]) + dp1[i][j]=max(dp1[i-1][j], dp2[i-1][j-1])+num[i-1] +print(max(dp1[n][m], dp2[n][m])) + From b1ae7c963347ff8c56ee512eb7e2e0e86e948b4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=84=9D=7CMinseok=20Kim?= Date: Sun, 24 Mar 2024 23:43:40 +0900 Subject: [PATCH 3/4] =?UTF-8?q?18=EC=B0=A8=EC=8B=9C=20=EB=AC=B8=EC=A0=9C?= =?UTF-8?q?=20=EC=84=A0=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- alstjr7437/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/alstjr7437/README.md b/alstjr7437/README.md index a9ac7f8..3524344 100644 --- a/alstjr7437/README.md +++ b/alstjr7437/README.md @@ -18,4 +18,5 @@ | 14차시 | 2024.03.03 | 브루트포스 | 마인크래프트 | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/48 | | 15차시 | 2024.03.09 | 우선순위 큐 | 파일 합치기3 | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/53 | | 16차시 | 2024.03.13 | 정렬 | 선 긋기 | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/57 | -| 17차시 | 2024.03.16 | DP | 구간 나누기 | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/61 | \ No newline at end of file +| 17차시 | 2024.03.16 | DP | 구간 나누기 | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/61 | +| 18차시 | 2024.03.23 | 다익스트라 | 최단 경로 | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/66 | \ No newline at end of file From bcde3c221fa4044ace5be99f1c6ca7f4fd81987a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=84=9D=7CMinseok=20Kim?= Date: Mon, 25 Mar 2024 02:58:29 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=EC=B5=9C=EB=8B=A8=EA=B2=BD=EB=A1=9C=20solv?= =?UTF-8?q?ed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...34\353\213\250\352\262\275\353\241\234.py" | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 "alstjr7437/\352\267\270\353\236\230\355\224\204/\354\265\234\353\213\250\352\262\275\353\241\234.py" diff --git "a/alstjr7437/\352\267\270\353\236\230\355\224\204/\354\265\234\353\213\250\352\262\275\353\241\234.py" "b/alstjr7437/\352\267\270\353\236\230\355\224\204/\354\265\234\353\213\250\352\262\275\353\241\234.py" new file mode 100644 index 0000000..c50db6d --- /dev/null +++ "b/alstjr7437/\352\267\270\353\236\230\355\224\204/\354\265\234\353\213\250\352\262\275\353\241\234.py" @@ -0,0 +1,40 @@ +from heapq import * +import sys + +input = sys.stdin.readline + +v, e = map(int, input().split()) +k = int(input()) + +# 그래프 만들기 +graph = [[] for _ in range(v + 1)] +for _ in range(e): + a, b, c = map(int, input().split()) + graph[a].append((c, b)) + +# 결과 저장할 변수 만들기 +heap = [] +result = [int(1e9)] * (v + 1) + +# k 넣기 +result[k] = 0 +heappush(heap, (0, k)) + +# 다익스트라 돌리기 +while heap: + weight, now = heappop(heap) + # print(weight,now, heap, result) + if result[now] < weight: + continue + for next_weight, next_node in graph[now]: + total_weight = weight + next_weight + if total_weight < result[next_node]: + result[next_node] = total_weight + heappush(heap, (total_weight, next_node)) + +# 결과 출력하기 +for i in range(1, v + 1): + if result[i] == int(1e9): + print("INF") + else: + print(result[i])