Skip to content

찬민 백준 숙제 #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions cmkim/BaekJoon/백준_17179.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
n, m, l = map(int, input().split())

cut = []
arr = []
for i in range(m): # 자르는 ��치
cut.append(int(input()))
#print(cut)

for i in range(n): # 자르는 횟수
arr.append(int(input()))

def calculate(mid, count): # 가장 작은 조각의 길이 > mid 일때 횟수를 세서 count 값이 만들어지면 성공
prev = 0
for i in range(m):
if cut[i] - prev >= mid:
count -= 1
prev = cut[i]
if count == 0:
break


if count == 0 and l - prev >= mid:
return True
else:
return False

for i in range(n):
piece = arr[i]
left = 0
right = l

while left + 1 < right:
mid = (left + right) // 2
if calculate(mid, piece):
left = mid
else:
right = mid

print(left)






48 changes: 48 additions & 0 deletions cmkim/BaekJoon/백준_4386.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import sys, math, heapq
n = int(input())

arr = []
connected = []
sum = 0
cost = 1e9

def dist(x1, y1, x2, y2):
return math.sqrt((x1 - x2)**2 + (y1 - y2)**2)

for i in range(n):
x, y = map(float, input().split())
arr.append((x, y))

q = []
connected.append(0)
for i in range(1, n):
heapq.heappush(q, (dist(arr[0][0], arr[0][1], arr[i][0], arr[i][1]), i))

# print(connected)
# print(q)

while n != len(connected):
value, node = heapq.heappop(q)
while node in connected:
value, node = heapq.heappop(q)

sum += value
connected.append(node)

for i in range(n):
if i not in connected:
heapq.heappush(q, (dist(arr[node][0], arr[node][1], arr[i][0], arr[i][1]), i))

print("%.2f"%(sum))