Skip to content

Commit 535d973

Browse files
Merge pull request #629 from Yujin-Baek/main
[백유진] 92차 라이브 코테 제출
2 parents cb10e08 + d2a5242 commit 535d973

3 files changed

Lines changed: 72 additions & 0 deletions

File tree

live9/test92/문제1/백유진.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import heapq
2+
3+
def solution(scoville, K):
4+
answer = 0
5+
heapq.heapify(scoville)
6+
7+
while scoville[0] < K:
8+
if len(scoville) <= 1:
9+
return -1
10+
first = heapq.heappop(scoville)
11+
second = heapq.heappop(scoville)
12+
13+
result = first + second*2
14+
15+
heapq.heappush(scoville, result)
16+
answer += 1
17+
18+
return answer

live9/test92/문제2/백유진.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
def solution(board, skill):
2+
n = len(board)
3+
m = len(board[0])
4+
5+
acc = [[0] * (m + 1) for _ in range(n + 1)]
6+
7+
# skill 명령 누적합 배열에 기록
8+
for t, r1, c1, r2, c2, degree in skill:
9+
diff = degree if t == 2 else -degree
10+
acc[r1][c1] += diff
11+
acc[r1][c2 + 1] -= diff
12+
acc[r2 + 1][c1] -= diff
13+
acc[r2 + 1][c2 + 1] += diff
14+
15+
# 가로 누적합
16+
for i in range(n):
17+
for j in range(1, m):
18+
acc[i][j] += acc[i][j - 1]
19+
20+
# 세로 누적합
21+
for j in range(m):
22+
for i in range(1, n):
23+
acc[i][j] += acc[i - 1][j]
24+
25+
answer = 0
26+
for i in range(n):
27+
for j in range(m):
28+
board[i][j] += acc[i][j]
29+
if board[i][j] > 0:
30+
answer += 1
31+
32+
return answer

live9/test92/문제3/백유진.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import heapq
2+
3+
def solution(book_time):
4+
reservations = []
5+
for start, end in book_time:
6+
h, m = map(int, start.split(":"))
7+
start_min = h * 60 + m
8+
h, m = map(int, end.split(":"))
9+
end_min = h * 60 + m + 10 # 청소 시간 포함
10+
reservations.append((start_min, end_min))
11+
reservations.sort()
12+
13+
rooms = []
14+
15+
for start, end in reservations:
16+
if rooms and rooms[0] <= start:
17+
# 기존 방 사용 가능
18+
heapq.heappop(rooms)
19+
# 새 방 배정 (또는 기존 방 갱신)
20+
heapq.heappush(rooms, end)
21+
22+
return len(rooms)

0 commit comments

Comments
 (0)