Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"Local: ATM","url":"d:\\AlgoLeadME-15\\AlgoLeadMe-15\\Seol-Munhyeok\\ATM.py","tests":[{"id":1756627725177,"input":"5\n3 1 4 3 2","output":"32"}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"d:\\AlgoLeadME-15\\AlgoLeadMe-15\\Seol-Munhyeok\\ATM.py","group":"local","local":true}
Original file line number Diff line number Diff line change
@@ -0,0 +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}
Original file line number Diff line number Diff line change
@@ -0,0 +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}
Original file line number Diff line number Diff line change
@@ -0,0 +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}
10 changes: 10 additions & 0 deletions Seol-Munhyeok/ATM.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
n = int(input())
lst = list(map(int, input().split()))

lst.sort()
p_sum = [0] * (n + 1)

for i in range(n):
p_sum[i + 1] = p_sum[i] + lst[i]

print(sum(p_sum))
6 changes: 5 additions & 1 deletion Seol-Munhyeok/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@
| 20차시 | 2025.08.14 | DP | [코딩 테스트 공부](https://school.programmers.co.kr/learn/courses/30/lessons/118668) | https://github.com/AlgoLeadMe/AlgoLeadMe-15/pull/73 |
AlgoLeadMe/AlgoLeadMe-15/pull/67 |
| 21차시 | 2025.08.18 | 시뮬레이션, 그리디 | [양궁 대회](https://school.programmers.co.kr/learn/courses/30/lessons/92342) | https://github.com/AlgoLeadMe/AlgoLeadMe-15/pull/75 |
| 22차시 | 2025.08.23 | 그리디, 투 포인터 | [두 큐 합 같게 만들기](https://school.programmers.co.kr/learn/courses/30/lessons/118667) | https://github.com/AlgoLeadMe/AlgoLeadMe-15/pull/79 |
| 22차시 | 2025.08.23 | 그리디, 투 포인터 | [두 큐 합 같게 만들기](https://school.programmers.co.kr/learn/courses/30/lessons/118667) | https://github.com/AlgoLeadMe/AlgoLeadMe-15/pull/79 |
| 23차시 | 2025.09.03 | 수학, 구현 | [책 페이지](https://www.acmicpc.net/problem/1019) | https://github.com/AlgoLeadMe/AlgoLeadMe-15/pull/84 |
| 24차시 | 2025.09.03 | 구현 | [수식 최대화](https://school.programmers.co.kr/learn/courses/30/lessons/67257) | https://github.com/AlgoLeadMe/AlgoLeadMe-15/pull/85 |
| 25차시 | 2025.09.06 | 문자열, 구현 | [방금그곡](https://school.programmers.co.kr/learn/courses/30/lessons/17683) | https://github.com/AlgoLeadMe/AlgoLeadMe-15/pull/86 |
| 26차시 | 2025.09.24 | 구현 | [로또의 최고 순위와 최저 순위](https://school.programmers.co.kr/learn/courses/30/lessons/77484) | https://github.com/AlgoLeadMe/AlgoLeadMe-15/pull/93 |
5 changes: 1 addition & 4 deletions Seol-Munhyeok/tempCodeRunnerFile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# 7 6 2 3 15 6 9 8
# 3 1 1 8 14 7 10 1
# 6 1 13 6 4 3 11 4
# 16 1 8 7 5 2 12 2
down
28 changes: 28 additions & 0 deletions Seol-Munhyeok/개똥벌레.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from bisect import bisect_left

# 입력 처리
N, H = map(int, input().split())
down, up = [], []
for i in range(N):
h = int(input())
if i % 2 == 0:
down.append(h)
else:
up.append(h)

down.sort()
up.sort()

best = int(1e9) # 파괴해야 하는 장애물의 최솟값
way = 1 # 구간의 수
for h in range(1, H + 1):
cnt_down = N // 2 - bisect_left(down, h)
cnt_up = N // 2 - bisect_left(up, H - h + 1)
cnt = cnt_down + cnt_up
if best > cnt:
best = cnt
way = 1
elif best == cnt:
way += 1

print(best, way)
28 changes: 28 additions & 0 deletions Seol-Munhyeok/개똥벌레2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import sys
input = sys.stdin.readline

N, H = map(int, input().split())

# line[i] = 높이 i에서 시작되는 충돌 변화량
line = [0] * H

for t in range(N):
h = int(input())
if t % 2 == 0: # 석순(아래에서 위로 올라옴)
line[0] += 1
line[h] -= 1
else: # 종유석(위에서 아래로 내려옴)
line[H - h] += 1

# prefix[y] = 높이 y에서 총 충돌 개수
prefix = [0] * (H + 1)
for i in range(H):
prefix[i + 1] = prefix[i] + line[i]

prefix = prefix[1:]

print(line)
print(prefix)
best = min(prefix)
way = prefix.count(best)
print(best, way)
28 changes: 28 additions & 0 deletions Seol-Munhyeok/로또의 최고 순위와 최저 순위.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
def get_rank(my_nums, win_nums):
my_nums.sort()
win_nums.sort()
count = 0
i = j = 0
while i < len(my_nums) and j < len(win_nums):
if my_nums[i] > win_nums[j]:
j += 1
elif my_nums[i] < win_nums[j]:
i += 1
else:
count += 1
i += 1
j += 1

return count

def solution(lottos, win_nums):
lottos.sort()
zero_count = lottos.count(0)
visible_nums = lottos[zero_count:]

temp = get_rank(visible_nums, win_nums)
min_rank = 6 if temp <= 1 else 7 - temp
temp += zero_count
max_rank = 6 if temp <= 1 else 7 - temp

return [max_rank, min_rank]
52 changes: 52 additions & 0 deletions Seol-Munhyeok/로봇청소기.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
def solution(r, c, d, grid):
dirs = [(-1, 0), (0, 1), (1, 0), (0, -1)]

y, x, cur_dir = r, c, d
cleaned = 0

while True:
# 현재 칸 청소
if grid[y][x] == 0:
grid[y][x] = 2
cleaned += 1

moved = False

# 왼쪽부터 4방향 검사
for _ in range(4):
left = (cur_dir + 3) % 4
dy, dx = dirs[left]
ny, nx = y + dy, x + dx

if grid[ny][nx] == 0:
# 왼쪽이 미청소면 회전 + 전진
cur_dir = left
y, x = ny, nx
moved = True
break
else:
# 왼쪽이 아니면
cur_dir = left

if moved:
continue

# 4 방향 모두 불가 -> 뒤로 한 칸 (방향은 유지)
back = (cur_dir + 2) % 4
dy, dx = dirs[back]
ny, nx = y + dy, x + dx

# 뒤가 벽이면 종료
if grid[ny][nx] == 1:
return cleaned

# 뒤로 이동 (바라보는 방향 cur는 그대로 유지)
y, x = ny, nx


# 입력 처리
n, m = map(int, input().split())
r, c, d = map(int, input().split())
grid = [list(map(int, input().split())) for _ in range(n)]

print(solution(r, c, d, grid))
12 changes: 12 additions & 0 deletions Seol-Munhyeok/매우어려운문제.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
n, m = map(int, input().split())

def solution(n, m):
if n > m:
return 0
tmp = 1
for i in range(2, n+1):
tmp = (tmp * i) % m
return tmp

print(solution(n, m))

32 changes: 32 additions & 0 deletions Seol-Munhyeok/방금그곡.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
def time_to_sec(time):
h, m = time.split(":")
return 60 * int(h) + int(m)

def convert(score):
lst = [("B#", "b"), ("C#", "c"), ("D#", "d"), ("E#", "e"), ("F#", "f"), ("G#", "g"), ("A#", "a")]
for a, b in lst:
score = score.replace(a, b)
return score

def convert_2(score, length):
size = len(score)
if size == length:
return score
if size > length:
return score[:length]
if size < length:
return score * (length // size) + score[:length % size]


def solution(m, musicinfos):
answer = '(None)'
max_size = -1
for info in musicinfos:
start, end, title, score = info.split(",")
length = time_to_sec(end) - time_to_sec(start)
m, score = convert(m), convert(score)
if m in convert_2(score, length) and length > max_size:
answer = title
max_size = length

return answer
43 changes: 43 additions & 0 deletions Seol-Munhyeok/수식최대화.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from itertools import permutations

def solution(expression):
# 토큰 분리
token = []
operators = set()
num = ''
for e in expression:
if e.isdigit():
num += e
else:
token.append(int(num))
token.append(e)
operators.add(e)
num = ''
token.append(int(num))

max_val = -1
# 모든 우선 순위 고려
for ops in permutations(operators):
temp = token[:]
# 연산자 우선 순위대로 처리
for op in ops:
stack = []
i = 0
while i < len(temp):
if temp[i] == op:
val_1 = stack.pop()
val_2 = temp[i + 1]
if op == '+':
stack.append(val_1 + val_2)
elif op == '-':
stack.append(val_1 - val_2)
elif op == '*':
stack.append(val_1 * val_2)
i += 2
else:
stack.append(temp[i])
i += 1
temp = stack
max_val = max(max_val, abs(temp[0]))

return max_val
28 changes: 28 additions & 0 deletions Seol-Munhyeok/차량배치.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from collections import defaultdict, deque
import sys

input = sys.stdin.readline
N, M = map(int, input().split())
graph = defaultdict(list)
for _ in range(M):
a, b = map(int, input().split())
graph[a].append(b)
graph[b].append(a)

visited = [False] * (N+1)
queue = deque()
queue.append(1)
visited[1] = True
answer = 1

while queue:
size = len(queue)
answer *= (size + 1)
for _ in range(size):
cur = queue.popleft()
for neighbor in graph[cur]:
if not visited[neighbor]:
queue.append(neighbor)
visited[neighbor] = True

print((answer - 1) % 1_000_000_007)
48 changes: 48 additions & 0 deletions Seol-Munhyeok/책 페이지.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
answer = [0] * 10 # 0~9 각 숫자의 총 등장 횟수를 담을 배열

start = 1 # 왼쪽 포인터: 아직 세지 않은 최소 숫자
end = int(input()) # 오른쪽 포인터: 아직 세지 않은 최대 숫자(입력 N)
ten = 1 # 현재 바라보는 자릿값(일=1, 십=10, 백=100, ...)

# 숫자 n이 지금 바라보는 자릿값(ten=1,10,100,...)에서
# '접두사'로서 기여하는 고정 등장 횟수를 answer에 더한다.
# 예를들어 calc(12345, 1)은 answer[5], answer[4], ... answer[1]에 +1
# +ten을 하는 이유는 현재 자리 아래쪽에는 항상 ten가지(0..ten-1)의 조합이 깔리므로,
# 그 자리의 같은 숫자 d가 블록 안에서 정확히 ten번 등장하기 때문.
def calc(n, ten):
while n > 0:
answer[n % 10] += ten
n //= 10

# 바깥 while 한 바퀴 = 자릿값 'ten' 하나를 완전히 처리
while start <= end:
# [1] 왼쪽 모서리 정리: start를 '...0'으로 맞출 때까지 개별 처리
while start % 10 != 0 and start <= end:
calc(start, ten)
start += 1
if start > end: break # 다 끝나면 종료

# [2] 오른쪽 모서리 정리: end를 '...9'로 맞출 때까지 개별 처리
while end % 10 != 9 and start <= end:
calc(end, ten)
end -= 1

# 여기까지 오면 [start, end]는 현재 자리에서
# 정확히 '...0 ~ ...9'가 반복되는 '완전 주기 구간'이 됨.

# [3] 가운데 완전 주기 한 번에 더하기
# cnt = 현재 자리에서 서로 다른 '접두사' 개수
# (접두사 하나마다 0~9 각 숫자가 하위 ten가지와 결합하므로
# 각 숫자가 정확히 'ten'번씩 등장)
cnt = (end // 10) - (start) // 10 + 1
for d in range(0, 10):
answer[d] += cnt * ten

# [4] 한 자리 올림: 현재 자리 처리를 끝냈으니 윗자리로 이동
start //= 10
end //= 10
ten *= 10

# 결과 출력
for d in range(0, 10):
print(answer[d], end=' ')
37 changes: 37 additions & 0 deletions Seol-Munhyeok/토마토.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from collections import deque
import sys

m, n = map(int, input().split())
arr = []
dy, dx = [-1, 0, 1, 0], [0, 1, 0, -1]
queue = deque()

# 입력 처리, 1인 좌표 저장
for i in range(n):
row = []
for j, val in enumerate(map(int, input().split())):
row.append(val)
if val == 1:
queue.append((i, j))
arr.append(row)

# BFS
while queue:
y, x = queue.popleft()
for i in range(4):
ny, nx = y + dy[i], x + dx[i]
if 0 <= ny < n and 0 <= nx < m and arr[ny][nx] == 0:
arr[ny][nx] = arr[y][x] + 1
queue.append((ny, nx))

# 정답 찾기
answer = -1e9
for i in range(n):
for j in range(m):
if arr[i][j] == 0:
print(-1)
sys.exit()
if arr[i][j] > answer:
answer = arr[i][j]

print(answer - 1)