Skip to content
Merged
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
34 changes: 34 additions & 0 deletions live8/test86/문제1/박희경.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import sys


def binary_search(arr, target):
start, end = 0, max(arr)

while start <= end:
mid = (start + end) // 2
high = 0
for i in arr:
if i > mid:
high += i - mid
if high < target: # 높이를 낮출 필요가 있음
end = mid - 1
else: # target이랑 일치해도 최대 높이를 구해야하니까
start = mid + 1
return end


input = sys.stdin.readline

n, m = map(int, input().split())
h = list(map(int, input().split()))

h.sort() # 10, 15, 17, 20
print(binary_search(h, m))

"""
4 7
20 15 10 17

5 20
4 42 40 26 46
"""
39 changes: 39 additions & 0 deletions live8/test86/문제2/박희경.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import sys


def binary_search(arr, target):
start, end = 0, max(arr)
while start <= end:
mid = (start + end) // 2
total = 0
for i in arr:
if i > mid:
total += mid
else:
total += i
if total > target:
end = mid - 1
else:
start = mid + 1
return end


input = sys.stdin.readline

n = int(input())
budget = list(map(int, input().split()))
m = int(input())

budget.sort() # 110 120 140 150
print(binary_search(budget, m))


"""
4
120 110 140 150
485

5
70 80 30 40 100
450
"""
22 changes: 22 additions & 0 deletions live8/test86/문제3/박희경.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
def solution(files):
answer = []
head, number, tail = '', '', ''

for file in files:
for i in range(len(file)):
if file[i].isdigit():
head = file[:i]
number = file[i:]
for j in range(len(number)):
if not number[j].isdigit():
tail = number[j:]
number = number[:j]
break

answer.append([head, number, tail])
head, number, tail = '', '', ''
break

answer = sorted(answer, key=lambda x: (x[0].lower(), int(x[1])))

return [''.join(i) for i in answer]