Skip to content

Commit 61949bd

Browse files
Merge pull request #595 from gmlrude/main
[박희경] 84차 라이브 코테 제출
2 parents d7472cf + 2c9518f commit 61949bd

3 files changed

Lines changed: 94 additions & 0 deletions

File tree

live8/test84/문제1/박희경.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import sys
2+
3+
input = sys.stdin.readline
4+
5+
6+
def binary_search(arr, target):
7+
start, end = 0, m - 1
8+
cnt = 0
9+
while start <= end:
10+
mid = (start + end) // 2
11+
if arr[mid] < target: # 먹이가 작은 상황
12+
cnt = mid + 1
13+
start = mid + 1
14+
else: # 먹이가 더 큰 상황
15+
end = mid - 1
16+
return cnt
17+
18+
19+
t = int(input())
20+
for _ in range(t):
21+
n, m = map(int, input().split())
22+
a = list(map(int, input().split()))
23+
b = list(map(int, input().split()))
24+
25+
b.sort()
26+
result = 0
27+
for i in range(len(a)):
28+
result += binary_search(b, a[i])
29+
print(result)
30+
31+
"""
32+
2
33+
5 3
34+
8 1 7 3 1
35+
3 6 1
36+
3 4
37+
2 13 7
38+
103 11 290 215
39+
"""

live8/test84/문제2/박희경.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import sys
2+
3+
input = sys.stdin.readline
4+
5+
6+
def binary_search(cables):
7+
start, end = 1, max(cables)
8+
while start <= end:
9+
mid = (start + end) // 2 # 반으로 자른 길이
10+
cnt = 0
11+
for cable in cables:
12+
cnt += cable // mid
13+
if cnt < n: # 길이를 줄일 필요가 있음
14+
end = mid - 1
15+
else:
16+
start = mid + 1 # 놓친 부분) 최대를 구해야 하니까..!
17+
return end
18+
19+
20+
k, n = map(int, input().split())
21+
cm = []
22+
for _ in range(k):
23+
cm.append(int(input()))
24+
25+
print(binary_search(cm))
26+
27+
28+
"""
29+
4 11
30+
802
31+
743
32+
457
33+
539
34+
"""

live8/test84/문제3/박희경.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def solution(skill, skill_trees):
2+
answer = 0
3+
4+
def is_possible(stack, skill):
5+
i, j = 0, 0
6+
while i < len(stack) and j < len(skill):
7+
if stack[i] == skill[j]:
8+
i += 1
9+
j += 1
10+
else:
11+
return False
12+
return True
13+
14+
for skills in skill_trees:
15+
stack = []
16+
for s in skills:
17+
if s in skill: # 순서가 중요한 스킬만
18+
stack.append(s)
19+
if is_possible(stack, skill):
20+
answer += 1
21+
return answer

0 commit comments

Comments
 (0)