Skip to content

Commit

Permalink
Merge pull request #223 from AlgoLeadMe/67-tgyuuAn
Browse files Browse the repository at this point in the history
67-tgyuuAn
  • Loading branch information
tgyuuAn authored Aug 6, 2024
2 parents 09bd4d2 + 3c17f12 commit 243234a
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
78 changes: 78 additions & 0 deletions tgyuuAn/DP/성냥개비.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import sys

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

T = int(input())
for _ in range(T):
count = int(input())
DP = [[str(int(1e17)), "0"] for _ in range(count+1)]
DP[0][0] = "0"

for now_idx in range(count):
if now_idx + 2 <= count:
if int(DP[now_idx + 2][0]) > int(DP[now_idx][0] + "1"):
DP[now_idx + 2][0] = DP[now_idx][0] + "1"

if int(DP[now_idx + 2][1]) < int(DP[now_idx][1] + "1"):
DP[now_idx + 2][1] = DP[now_idx][1] + "1"

if now_idx + 3 <= count:
if int(DP[now_idx + 3][0]) > int(DP[now_idx][0] + "7"):
DP[now_idx + 3][0] = DP[now_idx][0] + "7"

if int(DP[now_idx + 3][1]) < int(DP[now_idx][1] + "7"):
DP[now_idx + 3][1] = DP[now_idx][1] + "7"

if now_idx + 4 <= count:
if int(DP[now_idx + 4][0]) > int(DP[now_idx][0] + "4"):
DP[now_idx + 4][0] = DP[now_idx][0] + "4"

if int(DP[now_idx + 4][1]) < int(DP[now_idx][1] + "4"):
DP[now_idx + 4][1] = DP[now_idx][1] + "4"

if now_idx + 5 <= count:
if int(DP[now_idx + 5][0]) > int(DP[now_idx][0] + "3"):
DP[now_idx + 5][0] = DP[now_idx][0] + "3"

if int(DP[now_idx + 5][1]) < int(DP[now_idx][1] + "3"):
DP[now_idx + 5][1] = DP[now_idx][1] + "3"

if int(DP[now_idx + 5][0]) > int(DP[now_idx][0] + "2"):
DP[now_idx + 5][0] = DP[now_idx][0] + "2"

if int(DP[now_idx + 5][1]) < int(DP[now_idx][1] + "2"):
DP[now_idx + 5][1] = DP[now_idx][1] + "2"

if int(DP[now_idx + 5][0]) > int(DP[now_idx][0] + "5"):
DP[now_idx + 5][0] = DP[now_idx][0] + "5"

if int(DP[now_idx + 5][1]) < int(DP[now_idx][1] + "5"):
DP[now_idx + 5][1] = DP[now_idx][1] + "5"

if now_idx + 6 <= count:
if int(DP[now_idx + 6][0]) > int(DP[now_idx][0] + "6"):
DP[now_idx + 6][0] = DP[now_idx][0] + "6"

if int(DP[now_idx + 6][1]) < int(DP[now_idx][1] + "6"):
DP[now_idx + 6][1] = DP[now_idx][1] + "6"

if int(DP[now_idx + 6][0]) > int(DP[now_idx][0] + "9"):
DP[now_idx + 6][0] = DP[now_idx][0] + "9"

if int(DP[now_idx + 6][1]) < int(DP[now_idx][1] + "9"):
DP[now_idx + 6][1] = DP[now_idx][1] + "9"

if int(DP[now_idx][0]) != 0 and int(DP[now_idx + 6][0]) > int(DP[now_idx][0] + "0"):
DP[now_idx + 6][0] = DP[now_idx][0] + "0"

if int(DP[now_idx][0]) != 0 and int(DP[now_idx + 6][1]) < int(DP[now_idx][1] + "0"):
DP[now_idx + 6][1] = DP[now_idx][1] + "0"

if now_idx + 7 <= count:
if int(DP[now_idx + 7][0]) > int(DP[now_idx][0] + "8"):
DP[now_idx + 7][0] = DP[now_idx][0] + "8"

if int(DP[now_idx + 7][1]) < int(DP[now_idx][1] + "8"):
DP[now_idx + 7][1] = DP[now_idx][1] + "8"

print(int(DP[-1][0]), int(DP[-1][1]))
2 changes: 2 additions & 0 deletions tgyuuAn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@
| 60차시 | 2024.06.07 | 그리디 | <a href="https://www.acmicpc.net/problem/14939">불 끄기</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/209
| 61차시 | 2024.06.20 | 크루스칼 | <a href="https://www.acmicpc.net/problem/1774">우주신과의 교감</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/212
| 62차시 | 2024.07.01 | DP | <a href="https://www.acmicpc.net/problem/1949">우수 마을</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/214
| 63차시 | 2024.07.08 | BFS | <a href="https://www.acmicpc.net/problem/3108">로고</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/216
| 62차시 | 2024.07.01 | DP | <a href="https://www.acmicpc.net/problem/1949">우수 마을</a> | https://github.com/AlgoLeadMe/AlgoLeadMse-1/pull/214
| 63차시 | 2024.07.08 | BFS | <a href="https://www.acmicpc.net/problem/3108">로고</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/216
| 64차시 | 2024.07.12 | 최소 공통 조상 | <a href="https://www.acmicpc.net/problem/11812">K진 트리</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/217
| 65차시 | 2024.07.19 | 최소 공통 조상 | <a href="https://www.acmicpc.net/problem/3584">가장 가까운 공통 조상</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/220
| 66차시 | 2024.07.22 | DP | <a href="https://www.acmicpc.net/problem/2169">로봇 조종하기</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/222
| 67차시 | 2024.07.26 | DP | <a href="https://www.acmicpc.net/problem/3687">성냥개비</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/223
---

0 comments on commit 243234a

Please sign in to comment.