Skip to content

Commit f18e210

Browse files
Merge pull request #628 from gmlrude/main
[박희경] 92차 라이브 코테 제출
2 parents 535d973 + d46c16e commit f18e210

3 files changed

Lines changed: 70 additions & 0 deletions

File tree

live9/test92/문제1/박희경.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import heapq
2+
3+
def solution(scoville, K):
4+
answer = 0
5+
heap = []
6+
for s in scoville:
7+
heapq.heappush(heap, s)
8+
9+
res = 0
10+
while True:
11+
min_value = heapq.heappop(heap)
12+
if len(heap) == 0 and min_value < K:
13+
return -1
14+
if min_value < K:
15+
res = min_value + (heapq.heappop(heap) * 2)
16+
heapq.heappush(heap, res)
17+
answer += 1
18+
else:
19+
break
20+
21+
return answer

live9/test92/문제2/박희경.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
def solution(board, skill):
2+
answer = 0
3+
n = len(board)
4+
m = len(board[0])
5+
6+
degree = [[0] * (m + 1) for _ in range(n + 1)]
7+
for type, r1, c1, r2, c2, d in skill:
8+
d = -d if type == 1 else d
9+
degree[r1][c1] += d
10+
degree[r1][c2 + 1] -= d
11+
degree[r2 + 1][c1] -= d
12+
degree[r2 + 1][c2 + 1] += d
13+
14+
# 행기준 ->
15+
for i in range(n):
16+
for j in range(m):
17+
degree[i][j+1] += degree[i][j]
18+
19+
# 열 기준 ↓
20+
for j in range(m):
21+
for i in range(n):
22+
degree[i+1][j] += degree[i][j]
23+
24+
for i in range(n):
25+
for j in range(m):
26+
board[i][j] += degree[i][j]
27+
28+
29+
return sum(1 for row in board for cell in row if cell > 0)

live9/test92/문제3/박희경.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import heapq
2+
3+
def solution(book_time):
4+
5+
def hour_to_minute(time):
6+
h, m = map(int, time.split(":"))
7+
return h * 60 + m
8+
9+
book = sorted(list([hour_to_minute(start), hour_to_minute(end) + 10] for start, end in book_time))
10+
11+
room = []
12+
for start, end in book:
13+
# 현재 예약 시작 시간보다 가장 빨리 퇴실 시간 + 10분보다 이후라면 예약 가능 (갱신)
14+
if room and start >= room[0]:
15+
heapq.heappop(room)
16+
17+
# 현재 예약 종료 시간을 힙에 추가 (새로운 방 사용)
18+
heapq.heappush(room, end)
19+
20+
return len(room)

0 commit comments

Comments
 (0)