-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
473 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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=" ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | | ||
|
||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) + ">") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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=" ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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=" ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.