Skip to content

Commit 7cb5876

Browse files
committed
2025-09-06
1 parent b04ea2a commit 7cb5876

7 files changed

+114
-5
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"Local: 개똥벌레","url":"d:\\AlgoLeadME-15\\AlgoLeadMe-15\\Seol-Munhyeok\\개똥벌레.py","tests":[{"id":1756972182171,"input":"14 5\n1\n3\n4\n2\n2\n4\n3\n4\n3\n3\n3\n2\n3\n3","output":"7 2"},{"id":1756972205164,"input":"6 7\n1\n5\n3\n3\n5\n1","output":"2 3"}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"d:\\AlgoLeadME-15\\AlgoLeadMe-15\\Seol-Munhyeok\\개똥벌레.py","group":"local","local":true}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"Local: 개똥벌레2","url":"d:\\AlgoLeadME-15\\AlgoLeadMe-15\\Seol-Munhyeok\\개똥벌레2.py","tests":[{"id":1756973855147,"input":"14 5\n1\n3\n4\n2\n2\n4\n3\n4\n3\n3\n3\n2\n3\n3","output":"7 2"},{"id":1756974701757,"input":"6 7\n1\n5\n3\n3\n5\n1","output":"2 3"}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"d:\\AlgoLeadME-15\\AlgoLeadMe-15\\Seol-Munhyeok\\개똥벌레2.py","group":"local","local":true}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"Local: 차량배치","url":"d:\\AlgoLeadME-15\\AlgoLeadMe-15\\Seol-Munhyeok\\차량배치.py","tests":[{"id":1756981134725,"input":"3 3\n1 2\n1 3\n2 3","output":"5"},{"id":1756981248426,"input":"3 2\n1 2\n2 3","output":"7"},{"id":1756981481893,"input":"6 5\n1 2\n1 3\n2 4\n2 5\n3 6","output":"23"},{"id":1756981635073,"input":"1 0\n","output":"1"}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"d:\\AlgoLeadME-15\\AlgoLeadMe-15\\Seol-Munhyeok\\차량배치.py","group":"local","local":true}

Seol-Munhyeok/개똥벌레.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
1+
from bisect import bisect_left
2+
13
# 입력 처리
2-
n, h = map(int, input().split())
4+
N, H = map(int, input().split())
35
down, up = [], []
4-
for i in range(n):
5-
num = int(input())
6+
for i in range(N):
7+
h = int(input())
68
if i % 2 == 0:
7-
down.append(num)
9+
down.append(h)
810
else:
9-
up.append(num)
11+
up.append(h)
12+
13+
down.sort()
14+
up.sort()
1015

16+
best = int(1e9) # 파괴해야 하는 장애물의 최솟값
17+
way = 1 # 구간의 수
18+
for h in range(1, H + 1):
19+
cnt_down = N // 2 - bisect_left(down, h)
20+
cnt_up = N // 2 - bisect_left(up, H - h + 1)
21+
cnt = cnt_down + cnt_up
22+
if best > cnt:
23+
best = cnt
24+
way = 1
25+
elif best == cnt:
26+
way += 1
27+
28+
print(best, way)

Seol-Munhyeok/개똥벌레2.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import sys
2+
input = sys.stdin.readline
3+
4+
N, H = map(int, input().split())
5+
6+
# line[i] = 높이 i에서 시작되는 충돌 변화량
7+
line = [0] * H
8+
9+
for t in range(N):
10+
h = int(input())
11+
if t % 2 == 0: # 석순(아래에서 위로 올라옴)
12+
line[0] += 1
13+
line[h] -= 1
14+
else: # 종유석(위에서 아래로 내려옴)
15+
line[H - h] += 1
16+
17+
# prefix[y] = 높이 y에서 총 충돌 개수
18+
prefix = [0] * (H + 1)
19+
for i in range(H):
20+
prefix[i + 1] = prefix[i] + line[i]
21+
22+
prefix = prefix[1:]
23+
24+
print(line)
25+
print(prefix)
26+
best = min(prefix)
27+
way = prefix.count(best)
28+
print(best, way)

Seol-Munhyeok/방금그곡.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
def time_to_sec(time):
2+
h, m = time.split(":")
3+
return 60 * int(h) + int(m)
4+
5+
def convert(score):
6+
lst = [("B#", "b"), ("C#", "c"), ("D#", "d"), ("E#", "e"), ("F#", "f"), ("G#", "g"), ("A#", "a")]
7+
for a, b in lst:
8+
score = score.replace(a, b)
9+
return score
10+
11+
def convert_2(score, length):
12+
size = len(score)
13+
if size == length:
14+
return score
15+
if size > length:
16+
return score[:length]
17+
if size < length:
18+
return score * (length // size) + score[:length % size]
19+
20+
21+
def solution(m, musicinfos):
22+
answer = '(None)'
23+
max_size = -1
24+
for info in musicinfos:
25+
start, end, title, score = info.split(",")
26+
length = time_to_sec(end) - time_to_sec(start)
27+
m, score = convert(m), convert(score)
28+
if m in convert_2(score, length) and length > max_size:
29+
answer = title
30+
max_size = length
31+
32+
return answer

Seol-Munhyeok/차량배치.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from collections import defaultdict, deque
2+
import sys
3+
4+
input = sys.stdin.readline
5+
N, M = map(int, input().split())
6+
graph = defaultdict(list)
7+
for _ in range(M):
8+
a, b = map(int, input().split())
9+
graph[a].append(b)
10+
graph[b].append(a)
11+
12+
visited = [False] * (N+1)
13+
queue = deque()
14+
queue.append(1)
15+
visited[1] = True
16+
answer = 1
17+
18+
while queue:
19+
size = len(queue)
20+
answer *= (size + 1)
21+
for _ in range(size):
22+
cur = queue.popleft()
23+
for neighbor in graph[cur]:
24+
if not visited[neighbor]:
25+
queue.append(neighbor)
26+
visited[neighbor] = True
27+
28+
print((answer - 1) % 1_000_000_007)

0 commit comments

Comments
 (0)