Skip to content

Commit e98bce0

Browse files
Merge pull request #600 from gmlrude/main
[박희경] 86차 라이브 코테 제출
2 parents f2a20f7 + 9aa7b72 commit e98bce0

3 files changed

Lines changed: 95 additions & 0 deletions

File tree

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import sys
2+
3+
4+
def binary_search(arr, target):
5+
start, end = 0, max(arr)
6+
7+
while start <= end:
8+
mid = (start + end) // 2
9+
high = 0
10+
for i in arr:
11+
if i > mid:
12+
high += i - mid
13+
if high < target: # 높이를 낮출 필요가 있음
14+
end = mid - 1
15+
else: # target이랑 일치해도 최대 높이를 구해야하니까
16+
start = mid + 1
17+
return end
18+
19+
20+
input = sys.stdin.readline
21+
22+
n, m = map(int, input().split())
23+
h = list(map(int, input().split()))
24+
25+
h.sort() # 10, 15, 17, 20
26+
print(binary_search(h, m))
27+
28+
"""
29+
4 7
30+
20 15 10 17
31+
32+
5 20
33+
4 42 40 26 46
34+
"""

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import sys
2+
3+
4+
def binary_search(arr, target):
5+
start, end = 0, max(arr)
6+
while start <= end:
7+
mid = (start + end) // 2
8+
total = 0
9+
for i in arr:
10+
if i > mid:
11+
total += mid
12+
else:
13+
total += i
14+
if total > target:
15+
end = mid - 1
16+
else:
17+
start = mid + 1
18+
return end
19+
20+
21+
input = sys.stdin.readline
22+
23+
n = int(input())
24+
budget = list(map(int, input().split()))
25+
m = int(input())
26+
27+
budget.sort() # 110 120 140 150
28+
print(binary_search(budget, m))
29+
30+
31+
"""
32+
4
33+
120 110 140 150
34+
485
35+
36+
5
37+
70 80 30 40 100
38+
450
39+
"""

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
def solution(files):
2+
answer = []
3+
head, number, tail = '', '', ''
4+
5+
for file in files:
6+
for i in range(len(file)):
7+
if file[i].isdigit():
8+
head = file[:i]
9+
number = file[i:]
10+
for j in range(len(number)):
11+
if not number[j].isdigit():
12+
tail = number[j:]
13+
number = number[:j]
14+
break
15+
16+
answer.append([head, number, tail])
17+
head, number, tail = '', '', ''
18+
break
19+
20+
answer = sorted(answer, key=lambda x: (x[0].lower(), int(x[1])))
21+
22+
return [''.join(i) for i in answer]

0 commit comments

Comments
 (0)