Skip to content

Commit

Permalink
Merge branch 'main' into 46-tgyuuAn
Browse files Browse the repository at this point in the history
  • Loading branch information
tgyuuAn authored Apr 22, 2024
2 parents e6187a1 + 318bf96 commit e9416a4
Show file tree
Hide file tree
Showing 16 changed files with 473 additions and 26 deletions.
26 changes: 26 additions & 0 deletions H0ngJu/DP/1,2,3 ๋”ํ•˜๊ธฐ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import sys

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

T = int(input())

answer = []
dp = [0] * (11)

for index in range(T):
data = int(input())

for i in range(1, data + 1):
if i == 1:
dp[i] = 1
elif i == 2:
dp[i] = 2
elif i == 3:
dp[i] = 4
else:
dp[i] = dp[i-1] + dp[i-2] + dp[i-3]

answer.append(dp[data])

for a in answer:
print(a, end=" ")
13 changes: 10 additions & 3 deletions H0ngJu/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
## โœ๏ธ ๊ธฐ๋ก

| ์ฐจ์‹œ | ๋‚ ์งœ | ๋ฌธ์ œ์œ ํ˜• | ๋งํฌ | ํ’€์ด |
| :---: | :--------: | :------: | :-------------------------------------------------------------------------: | :-------------------------------------------------: |
| 1์ฐจ์‹œ | 2024.03.05 | ํ | [ํ”„๋กœ์„ธ์Šค](https://school.programmers.co.kr/learn/courses/30/lessons/42587) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/151 |
| ์ฐจ์‹œ | ๋‚ ์งœ | ๋ฌธ์ œ์œ ํ˜• | ๋งํฌ | ํ’€์ด |
| :---: | :--------: | :------: | :-----------------------------------------------------------------------------------: | :-------------------------------------------------: |
| 1์ฐจ์‹œ | 2024.03.05 | ํ | [ํ”„๋กœ์„ธ์Šค](https://school.programmers.co.kr/learn/courses/30/lessons/42587) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/151 |
| 2์ฐจ์‹œ | 2024.03.07 | ํ | [๋‹ค๋ฆฌ๋ฅผ ์ง€๋‚˜๋Š” ํŠธ๋Ÿญ](https://school.programmers.co.kr/learn/courses/30/lessons/42583) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/153 |
| 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 |
| 8์ฐจ์‹œ | 2024.03.16 | DP | [์‰ฌ์šด ๊ณ„๋‹จ ์ˆ˜](https://www.acmicpc.net/problem/10844) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/170 |

---
27 changes: 27 additions & 0 deletions H0ngJu/๊ตฌํ˜„/์š”์„ธํ‘ธ์Šค.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import sys

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

def solution(k):
location = 0
cnt = 0

while table:
if cnt == k - 1:
answer.append(table.pop(location))
location -= 1 # ์‚ญ์ œํ•œ ๊ฒฝ์šฐ์—๋Š” ์œ„์น˜๋ฅผ ์•ž์œผ๋กœ ์ด๋™
cnt = 0
else:
cnt += 1
if len(table) != 0:
location = (location + 1) % len(table)

return answer

n, k = map(int, input().split())
table = [i + 1 for i in range(n)]
answer = []

solution(k)
print("<" + ", ".join(map(str, answer)) + ">")
28 changes: 28 additions & 0 deletions H0ngJu/์‰ฌ์šด ๊ณ„๋‹จ ์ˆ˜.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import sys

DIV = 1_000_000_000

N = int(sys.stdin.readline().rstrip())

dp = [[0] * 10 for _ in range(N+1)]
answer = 0

for i in range(1,N+1):
if i == 1:
for k in range(1,10):
dp[i][k] = 1

else:
for num in range(10):
if num == 0:
dp[i][num] = dp[i-1][1]%DIV
elif num == 9:
dp[i][num] = dp[i-1][8]%DIV
else:
dp[i][num] = (dp[i-1][num-1] + dp[i-1][num+1])%DIV

for k in range(10):
answer += dp[N][k]

print(answer%DIV)

25 changes: 25 additions & 0 deletions H0ngJu/์˜คํฐ์ˆ˜.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import sys
from collections import *

def input(): return sys.stdin.readline().strip()
N = int(input())

arr = list(map(int, input().split()))
arr.reverse()
answer = [-1 for _ in range(N)]

id = 0

stack = []
stack.append((id,arr.pop()))

while arr:
id += 1
arr_data = arr.pop()
while stack and stack[-1][1] < arr_data:
index, data = stack.pop()
answer[index] = arr_data
stack.append((id, arr_data))

for i in answer:
print(i, end=" ")
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from collections import deque

def solution(bridge_length, weight, truck_weights):
time = 0
onBridge = deque() # ํ˜„์žฌ ๋‹ค๋ฆฌ ์œ„์— ์žˆ๋Š” ํŠธ๋Ÿญ
truckNum = 0 # ํ˜„์žฌ ๋‹ค๋ฆฌ ์œ„์— ์žˆ๋Š” ํŠธ๋Ÿญ ์ˆ˜
sum = 0 # ํ˜„์žฌ ๋‹ค๋ฆฌ ์œ„์— ์žˆ๋Š” ํŠธ๋Ÿญ ๋ฌด๊ฒŒ์˜ ํ•ฉ
truck_weights = deque(truck_weights)

while truck_weights or onBridge:
time += 1

# ํŠธ๋Ÿญ์ด ๋‹ค๋ฆฌ๋ฅผ ์ง€๋‚˜๊ฐ€๋Š” ๊ฒฝ์šฐ ์ฒ˜๋ฆฌ
if onBridge and time - onBridge[0][1] >= bridge_length:
sum -= onBridge.popleft()[0]
truckNum -= 1

# ๋‹ค์Œ ํŠธ๋Ÿญ์ด ๋‹ค๋ฆฌ์— ์˜ฌ๋ผ๊ฐˆ ์ˆ˜ ์žˆ๋Š” ๊ฒฝ์šฐ ์ฒ˜๋ฆฌ
# ํŠธ๋Ÿญ์ด ์žˆ๊ณ  ํ•ฉ์ด weight์„ ๋„˜์ง€ ์•Š์œผ๋ฉฐ, ์ˆ˜๊ฐ€ bridge_length๋ฅผ ๋„˜๊ธฐ์ง€ ์•Š๋Š” ๊ฒฝ์šฐ
if len(truck_weights) != 0 and sum + truck_weights[0] <= weight and truckNum + 1 <= bridge_length:
truck = truck_weights.popleft() # pop
onBridge.append((truck, time)) # ๋‹ค๋ฆฌ ์œ„์˜ truck์— tuple ์ถ”๊ฐ€
sum += truck # ๋ฌด๊ฒŒ ์ถ”๊ฐ€
truckNum += 1 # ๊ฑด๋„ˆ๊ณ  ์žˆ๋Š” ํŠธ๋Ÿญ ์ถ”๊ฐ€

return time
19 changes: 19 additions & 0 deletions H0ngJu/ํž™/N๋ฒˆ์งธ ํฐ ์ˆ˜.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import sys
import heapq

line = int(sys.stdin.readline().strip())

heap = []
heapq.heapify(heap)

for i in range(line):
data = list(map(int, sys.stdin.readline().strip().split()))
for s in data:
if len(heap) < line:
heapq.heappush(heap, s)
else:
if s > heap[0]:
heapq.heappop(heap)
heapq.heappush(heap, s)

print(heap[0])
32 changes: 32 additions & 0 deletions H0ngJu/ํž™/๋ฌธ์ œ์ง‘.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import sys
import heapq

n, m = map(int, sys.stdin.readline().rstrip().split())

graph = [[] for _ in range(n+1)]
inDegree = [0 for _ in range(n+1)]
q = []
answer = []

# ์ž…๋ ฅ๋ฐ›์•„์„œ ๋„ฃ๊ธฐ
for _ in range(m):
p1, p2 = map(int, sys.stdin.readline().rstrip().split())
graph[p1].append(p2) # p1์€ p2์™€ ์—ฐ๊ฒฐ๋œ ๋ฌธ์ œ
inDegree[p2] += 1 # ๊ฐ„์„  ์ถ”๊ฐ€

# ์ง„์ž…์ฐจ์ˆ˜๊ฐ€ 0์ด๋ฉด ํ์— ๋„ฃ๊ธฐ
for i in range(1, n+1):
if inDegree[i] == 0:
heapq.heappush(q, i)

# answer์— ๋„ฃ๊ณ , ๊ฐ„์„  ์ œ๊ฑฐ
while q:
prob = heapq.heappop(q)
answer.append(prob)
for i in graph[prob]: # ๊ฐ„์„  ์ œ๊ฑฐ & ์ง„์ž…์ฐจ์ˆ˜ 0์ธ ๊ฒƒ๋“ค ์ฒ˜๋ฆฌ
inDegree[i] -= 1
if inDegree[i] == 0:
heapq.heappush(q, i)

for result in answer:
print(result, end=" ")
45 changes: 23 additions & 22 deletions pknujsp/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
## โœ๏ธ ๊ธฐ๋ก

| ์ฐจ์‹œ | ๋‚ ์งœ | ๋ฌธ์ œ์œ ํ˜• | ๋งํฌ | ํ’€์ด |
| :----: | :--------: | :-------------: | :-----------------------------------------------------------------------------------------------: | :--------------------------------------------------------: |
| 1์ฐจ์‹œ | 2023.10.07 | BRUTE_FORCE | [BOJ_1107](https://www.acmicpc.net/problem/1107) | [#2](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/2) |
| 2์ฐจ์‹œ | 2023.10.09 | BRUTE_FORCE | [์—ฐ์† ๋ถ€๋ถ„ ์ˆ˜์—ด ํ•ฉ์˜ ๊ฐœ์ˆ˜](https://school.programmers.co.kr/learn/courses/30/lessons/131701) | [#5](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/5) |
| 3์ฐจ์‹œ | 2023.10.11 | SORT | [์ตœ์†Ÿ๊ฐ’ ๋งŒ๋“ค๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/12941?language=python3) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/8) |
| 4์ฐจ์‹œ | 2023.10.13 | SORT | [ํŠœํ”Œ](https://school.programmers.co.kr/learn/courses/30/lessons/64065) | [#9](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/9) |
| 5์ฐจ์‹œ | 2023.10.15 | ๊ตฌํ˜„ | [๊ด„ํ˜ธ ๋ณ€ํ™˜](https://school.programmers.co.kr/learn/courses/30/lessons/60058) | [#13](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/13) |
| 6์ฐจ์‹œ | 2023.10.17 | ํƒ์ƒ‰ | [์ฟผ๋“œ์••์ถ• ํ›„ ๊ฐœ์ˆ˜ ์„ธ๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/68936) | [#16](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/16) |
| 7์ฐจ์‹œ | 2023.10.19 | ํƒ์ƒ‰ | [๋ฌด์ธ๋„ ์—ฌํ–‰](https://school.programmers.co.kr/learn/courses/30/lessons/154540) | [#20](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/20) |
| 8์ฐจ์‹œ | 2023.10.21 | ํƒ์ƒ‰ | [๊ฑฐ๋ฆฌ๋‘๊ธฐ ํ™•์ธํ•˜๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/81302) | [#22](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/22) |
| 9์ฐจ์‹œ | 2023.10.23 | ๋งต | [์Šคํ‚ฌ ํŠธ๋ฆฌ](https://school.programmers.co.kr/learn/courses/30/lessons/49993) | [#25](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/25) |
| 10์ฐจ์‹œ | 2023.10.25 | ๊ตฌํ˜„ | [์ˆ˜์‹ ์ตœ๋Œ€ํ™”](https://school.programmers.co.kr/learn/courses/30/lessons/67257) | [#28](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/28) |
| 11์ฐจ์‹œ | 2023.10.27 | ๋ฆฌ์ŠคํŠธ | [์˜์–ด ๋๋ง์ž‡๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/12981) | [#30](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/30) |
| 12์ฐจ์‹œ | 2023.10.30 | ํ | [์ด์ค‘์šฐ์„ ์ˆœ์œ„ํ](https://school.programmers.co.kr/learn/courses/30/lessons/42628) | [#36](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/36) |
| 13์ฐจ์‹œ | 2023.11.01 | DP | [๋“ฑ๊ตฃ๊ธธ](https://school.programmers.co.kr/learn/courses/30/lessons/42898) | [#39](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/39) |
| 14์ฐจ์‹œ | 2023.11.03 | ๋งต | [์‹œ์†Œ ์ง๊ฟ](https://school.programmers.co.kr/learn/courses/30/lessons/152996) | [#43](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/43) |
| 15์ฐจ์‹œ | 2023.11.05 | ์ˆ˜ํ•™ | [์˜ˆ์ƒ ๋Œ€์ง„ํ‘œ](https://school.programmers.co.kr/learn/courses/30/lessons/12985) | [#47](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/47) |
| 16์ฐจ์‹œ | 2023.11.08 | ์ˆ˜ํ•™ | [์ˆซ์ž ๋ณ€ํ™˜ํ•˜๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/154538) | [#51](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/51) |
| 17์ฐจ์‹œ | 2023.11.10 | ์Šคํƒ | [์ง์ง€์–ด ์ œ๊ฑฐํ•˜๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/12973) | [#54](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/54) |
| 18์ฐจ์‹œ | 2023.11.13 | ๊ตฌํ˜„ | [ํ‚คํŒจ๋“œ ๋ˆ„๋ฅด๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/67256) | [#60](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/60) |
| 19์ฐจ์‹œ | 2023.11.17 | ๊ตฌํ˜„ | [์‹คํŒจ์œจ](https://school.programmers.co.kr/learn/courses/30/lessons/42889) | [#64](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/64) |
| ์ฐจ์‹œ | ๋‚ ์งœ | ๋ฌธ์ œ์œ ํ˜• | ๋งํฌ | ํ’€์ด |
| :----: | :--------: | :-------------: | :-----------------------------------------------------------------------------------------------: | :---------------------------------------------------------: |
| 1์ฐจ์‹œ | 2023.10.07 | BRUTE_FORCE | [BOJ_1107](https://www.acmicpc.net/problem/1107) | [#2](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/2) |
| 2์ฐจ์‹œ | 2023.10.09 | BRUTE_FORCE | [์—ฐ์† ๋ถ€๋ถ„ ์ˆ˜์—ด ํ•ฉ์˜ ๊ฐœ์ˆ˜](https://school.programmers.co.kr/learn/courses/30/lessons/131701) | [#5](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/5) |
| 3์ฐจ์‹œ | 2023.10.11 | SORT | [์ตœ์†Ÿ๊ฐ’ ๋งŒ๋“ค๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/12941?language=python3) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/8) |
| 4์ฐจ์‹œ | 2023.10.13 | SORT | [ํŠœํ”Œ](https://school.programmers.co.kr/learn/courses/30/lessons/64065) | [#9](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/9) |
| 5์ฐจ์‹œ | 2023.10.15 | ๊ตฌํ˜„ | [๊ด„ํ˜ธ ๋ณ€ํ™˜](https://school.programmers.co.kr/learn/courses/30/lessons/60058) | [#13](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/13) |
| 6์ฐจ์‹œ | 2023.10.17 | ํƒ์ƒ‰ | [์ฟผ๋“œ์••์ถ• ํ›„ ๊ฐœ์ˆ˜ ์„ธ๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/68936) | [#16](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/16) |
| 7์ฐจ์‹œ | 2023.10.19 | ํƒ์ƒ‰ | [๋ฌด์ธ๋„ ์—ฌํ–‰](https://school.programmers.co.kr/learn/courses/30/lessons/154540) | [#20](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/20) |
| 8์ฐจ์‹œ | 2023.10.21 | ํƒ์ƒ‰ | [๊ฑฐ๋ฆฌ๋‘๊ธฐ ํ™•์ธํ•˜๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/81302) | [#22](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/22) |
| 9์ฐจ์‹œ | 2023.10.23 | ๋งต | [์Šคํ‚ฌ ํŠธ๋ฆฌ](https://school.programmers.co.kr/learn/courses/30/lessons/49993) | [#25](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/25) |
| 10์ฐจ์‹œ | 2023.10.25 | ๊ตฌํ˜„ | [์ˆ˜์‹ ์ตœ๋Œ€ํ™”](https://school.programmers.co.kr/learn/courses/30/lessons/67257) | [#28](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/28) |
| 11์ฐจ์‹œ | 2023.10.27 | ๋ฆฌ์ŠคํŠธ | [์˜์–ด ๋๋ง์ž‡๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/12981) | [#30](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/30) |
| 12์ฐจ์‹œ | 2023.10.30 | ํ | [์ด์ค‘์šฐ์„ ์ˆœ์œ„ํ](https://school.programmers.co.kr/learn/courses/30/lessons/42628) | [#36](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/36) |
| 13์ฐจ์‹œ | 2023.11.01 | DP | [๋“ฑ๊ตฃ๊ธธ](https://school.programmers.co.kr/learn/courses/30/lessons/42898) | [#39](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/39) |
| 14์ฐจ์‹œ | 2023.11.03 | ๋งต | [์‹œ์†Œ ์ง๊ฟ](https://school.programmers.co.kr/learn/courses/30/lessons/152996) | [#43](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/43) |
| 15์ฐจ์‹œ | 2023.11.05 | ์ˆ˜ํ•™ | [์˜ˆ์ƒ ๋Œ€์ง„ํ‘œ](https://school.programmers.co.kr/learn/courses/30/lessons/12985) | [#47](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/47) |
| 16์ฐจ์‹œ | 2023.11.08 | ์ˆ˜ํ•™ | [์ˆซ์ž ๋ณ€ํ™˜ํ•˜๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/154538) | [#51](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/51) |
| 17์ฐจ์‹œ | 2023.11.10 | ์Šคํƒ | [์ง์ง€์–ด ์ œ๊ฑฐํ•˜๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/12973) | [#54](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/54) |
| 18์ฐจ์‹œ | 2023.11.13 | ๊ตฌํ˜„ | [ํ‚คํŒจ๋“œ ๋ˆ„๋ฅด๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/67256) | [#60](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/60) |
| 19์ฐจ์‹œ | 2023.11.17 | ๊ตฌํ˜„ | [์‹คํŒจ์œจ](https://school.programmers.co.kr/learn/courses/30/lessons/42889) | [#64](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/64) |
| 20์ฐจ์‹œ | 2023.11.20 | ๋ฌธ์ž์—ด | [์˜น์•Œ์ด (2)](https://school.programmers.co.kr/learn/courses/30/lessons/133499) | [#70](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/70) |
| 21์ฐจ์‹œ | 2023.11.23 | ๋งต | [์˜์ƒ](https://school.programmers.co.kr/learn/courses/30/lessons/42578) | [#73](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/73) |
| 22์ฐจ์‹œ | 2023.11.26 | ๊ทธ๋ฆฌ๋”” | [๊ตฌ๋ช…๋ณดํŠธ](https://school.programmers.co.kr/learn/courses/30/lessons/42885) | [#79](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/79) |
Expand All @@ -37,4 +37,5 @@
| 33์ฐจ์‹œ | 2024.02.06 | ํ | [์ฒ ๋กœ](https://www.acmicpc.net/problem/13334) | [#132](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/132) |
| 34์ฐจ์‹œ | 2024.02.12 | BFS | [์ด๋ถ„ ๊ทธ๋ž˜ํ”„](https://www.acmicpc.net/problem/1707) | [#135](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/135) |
| 35์ฐจ์‹œ | 2024.02.18 | ๊ทธ๋ฆฌ๋”” | [์„ ๋ฌผํ• ์ธ](https://www.acmicpc.net/problem/25947) | [#137](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/137) |
| 36์ฐจ์‹œ | 2024.02.21 | ์ด์ง„ํƒ์ƒ‰ | [ํœด๊ฒŒ์†Œ ์„ธ์šฐ๊ธฐ](https://www.acmicpc.net/problem/1477) | [#143](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/143) |
| 36์ฐจ์‹œ | 2024.02.21 | ์ด์ง„ํƒ์ƒ‰ | [ํœด๊ฒŒ์†Œ ์„ธ์šฐ๊ธฐ](https://www.acmicpc.net/problem/1477) | [#143](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/143) |
| 37์ฐจ์‹œ | 2024.03.04 | ๊ตฌํ˜„ | [n+1 ์นด๋“œ๊ฒŒ์ž„](https://school.programmers.co.kr/learn/courses/30/lessons/258707) | [#149](https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/149) |
53 changes: 53 additions & 0 deletions pknujsp/๊ตฌํ˜„/37-์นด๋“œ๊ฒŒ์ž„.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
def solution(coin, cards):
a = set(cards[:len(cards) // 3])
b = set()
t = len(cards) + 1
r = 1

for i in range(len(cards) // 3 + 1, len(cards), 2):
c1, c2 = cards[i - 1], cards[i]
b.add(c1)
b.add(c2)

removed = False
# ํ˜„์žฌ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ์นด๋“œ ๋ชฉ๋ก ์ค‘ n + 1์ด ๊ฐ€๋Šฅํ•œ ๊ฒฝ์šฐ ํ™•์ธ
for x in list(a):
if t - x in a:
a.remove(t - x)
a.remove(x)
removed = True
break

if removed:
r += 1
continue

# ์ฝ”์ธ์œผ๋กœ ๊ตํ™˜ํ•ด์„œ ์–ป์„ ์ˆ˜ ์žˆ๋Š” ์นด๋“œ ์ค‘์—์„œ n + 1์ด ๋˜๋Š” ๊ฒฝ์šฐ๋ฅผ ์ฐพ์•„์•ผ ํ•จ
# ์ฝ”์ธ์ด ์—†์œผ๋ฏ€๋กœ ์ข…๋ฃŒ
if not coin:
break

# `ํ˜„์žฌ ๊ฐ–๊ณ  ์žˆ๋Š” ์นด๋“œ + ์–ป์„ ์ˆ˜ ์žˆ๋Š” ์นด๋“œ` = n + 1์ด ๋˜๋Š” ๊ฒฝ์šฐ๋ฅผ ํ™•์ธ
for x in list(b):
if t - x in a:
a.remove(t - x)
b.remove(x)
removed = True
coin -= 1
break
# ๋งˆ์ง€๋ง‰ ๋ฐฉ๋ฒ•์œผ๋กœ, ์˜ค์ง ๊ตํ™˜์œผ๋กœ ์–ป์„ ์ˆ˜ ์žˆ๋Š” ์นด๋“œ ๋ชฉ๋ก ์ค‘์—์„œ n + 1์ด ๋˜๋Š” ๊ฒฝ์šฐ๋ฅผ ํ™•์ธ
if not removed and coin >= 2:
for x in list(b):
if t - x in b:
b.remove(t - x)
b.remove(x)
removed = True
coin -= 2
break

# n + 1์„ ์–ด๋–ค ๊ฒฝ์šฐ์—๋„ ๋ชป ๋งŒ๋“ค๋ฉด ์ข…๋ฃŒ
if not removed:
break
r += 1

return r
Loading

0 comments on commit e9416a4

Please sign in to comment.