Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

13 ljedd2 #167

Merged
merged 12 commits into from
Nov 22, 2024
4 changes: 4 additions & 0 deletions LJEDD2/2024-2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@
| 6์ฐจ์‹œ | 2024.08.03 | ์™„์ „ํƒ์ƒ‰ | <a href="https://school.programmers.co.kr/learn/courses/30/lessons/87946">ํ”ผ๋กœ๋„</a> | [#6](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/141) |
| 7์ฐจ์‹œ | 2024.09.01 | ์œ„์ƒ์ •๋ ฌ | <a href="https://www.acmicpc.net/problem/2252">์ค„ ์„ธ์šฐ๊ธฐ</a> | [#7](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/152) |
| 8์ฐจ์‹œ | 2024.09.04 | ์œ„์ƒ์ •๋ ฌ | <a href="https://www.acmicpc.net/problem/1766">๋ฌธ์ œ์ง‘</a> | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/154) |
| 9์ฐจ์‹œ | 2024.09.07 | ์Šคํƒ | <a href="https://www.acmicpc.net/problem/2176">์›์ˆญ์ด ๋งค๋‹ฌ๊ธฐ</a> | [#9](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/156) |
| 10์ฐจ์‹œ | 2024.09.11 | ์šฐ์„ ์ˆœ์œ„ ํ | <a href="https://www.acmicpc.net/problem/1715">์นด๋“œ ์ •๋ ฌํ•˜๊ธฐ</a> | [#10](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/159) |
| 11์ฐจ์‹œ | 2024.09.18 | ์šฐ์„ ์ˆœ์œ„ ํ | <a href="https://www.acmicpc.net/problem/2075">N๋ฒˆ์งธ ํฐ ์ˆ˜</a> | [#11](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/161) |
| 12์ฐจ์‹œ | 2024.09.21 | ์šฐ์„ ์ˆœ์œ„ ํ | <a href="https://www.acmicpc.net/problem/15903">์นด๋“œ ํ•ฉ์ฒด ๋†€์ด</a> | [#12](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/164) |
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# ๋” ๊ฐ„๋‹จํ•œ ํ’€์ด ... (๋ฌธ์ž์—ด)
import sys
input = sys.stdin.readline

for _ in range(int(input())):
cnt = 0
s = input().rstrip()
while "[]" in s:
s = s.replace("[]", "")
cnt += 1

print(2**cnt)



# import sys

# input = sys.stdin.readline

# for _ in range(int(input())):
# s = input().rstrip() # ๊ด„ํ˜ธ ๋ฌธ์ž์—ด

# max_depth = 0 # ์ตœ๋Œ€ ๊นŠ์ด๋ฅผ ์ €์žฅํ•  ๋ณ€์ˆ˜
# tree = list() # ํ˜„์žฌ ์—ด๋ฆฐ ๊ด„ํ˜ธ๋ฅผ ์ €์žฅํ•  ์Šคํƒ์ž„

# for i in s:
# # ์—ฌ๋Š” ๊ด„ํ˜ธ์ผ ๊ฒฝ์šฐ ์Šคํƒ์— ์—ด๋ฆฐ ๊ด„ํ˜ธ ์ถ”๊ฐ€
# if i == '[':
# tree.append('[')
# continue
# # ๋‹ซ๋Š” ๊ด„ํ˜ธ์ผ ๊ฒฝ์šฐ
# max_depth = max(len(tree), max_depth)
# # ํ˜„์žฌ ๊นŠ์ด์™€ ์ตœ๋Œ€ ๊นŠ์ด ์ค‘ ํฐ ๊ฐ’์„ ์ €์žฅํ•˜๊ณ 
# tree.pop() # ๋งˆ์ง€๋ง‰ ์—ด๋ฆฐ ๊ด„ํ˜ธ๋ฅผ ์ œ๊ฑฐ

# print(2 ** max_depth) # ์Œ์„ ์ด๋ฃฐ๋•Œ ๊ฐ€์ง€ ์ƒ์„ฑ, ๊ฐ€์ง€2-.1๊ฐœ์”ฉ ๋‚˜๋ˆ ๊ฐ€์ง
# # ๊ฒฐ๊ตญ์—” 2์˜ depth์Šน
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import sys, heapq
input = sys.stdin.readline

n = int(input())
heap = []

for _ in range(n):
for number in map(int, input().split()):

if len(heap) < n: # ๋น„๊ต ๋Œ€์ƒ์ด ๋ชจ์ž๋ž„ ๊ฒฝ์šฐ
heapq.heappush(heap, number) #๊ทธ๋Œ€๋กœ ์ถ”๊ฐ€

else:
if number > heap[0]: # ์ œ์ผ ์ž‘์€๊ฒƒ๋ณด๋‹ค ํฌ๋ฉด
heapq.heapreplace(heap, number) #์ž‘์€๊ฑฐ ๋นผ๊ณ  ํฐ๊ฑฐ ๋„ฃ์–ด์คŒ

print(heap[0]) # ๋งจ์•ž์— ์žˆ๋Š”๊ฒŒ N๋ฒˆ์งธ๋กœ ํฐ๋†ˆ
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import sys
import heapq
input = sys.stdin.readline

cards = list(int(input()) for _ in range(int(input().strip()))) # ๋ฐ์ดํ„ฐ ์ž…๋ ฅ๋ฐ›์Œ
heapq.heapify(cards) # ๋ฆฌ์ŠคํŠธ๋ฅผ ํž™๊ตฌ์กฐ๋กœ ๋ฐ”๊ฟ”์ฃผ๋Š” ํ•จ์ˆ˜

result = 0
while len(cards) > 1 :
f = heapq.heappop(cards) # ์ฒซ๋ฒˆ์งธ ๋ญ‰ํƒฑ์ด
s = heapq.heappop(cards) # ๋‘๋ฒˆ์งธ ๋ญ‰ํƒฑ์ด

result += f+s

# ๋ฐ”๊ฟ”์น˜๊ธฐ ํšŸ์ˆ˜๊ฐ€ ์ตœ์†Œ๊ฐ€ ๋˜๊ฒŒ๋”
heapq.heappush(cards, f+s)

print(result)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import heapq
n, m = map(int,input().split())

#ํž™ ๊ตฌ์กฐ๋กœ ๋ณ€ํ™˜
numbers = list(map(int,input().split()))
heapq.heapify(numbers)

for _ in range(m):

x = heapq.heappop(numbers)
y = heapq.heappop(numbers)

# x์™€ y ๋‘˜ ๋‹ค ๊ฐ’ ๊ต์ฒด
heapq.heappush(numbers, x+y)
heapq.heappush(numbers, x+y)

print(sum(numbers))
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import sys
input = sys.stdin.readline

n = int(input())
graph = [list(input().strip()) for _ in range(n)]
visited = [[0] * n for _ in range(n)]

for k in range(n):
for i in range(n):
for j in range(n):
if i == j:
continue

# 2-์นœ๊ตฌ์ธ ๊ฒฝ์šฐ
if graph[i][j] == 'Y' or (graph[i][k] == 'Y' and graph[k][j] == 'Y'):
visited [i][j] = 1

res = 0
for row in visited:
res = max(res,sum(row))
print(res)