목록Python (215)
가오리의 코딩일기
def three_search(start, end): while abs(end - start) > 1e-9: mid1 = (2 * start + end) / 3 mid2 = (start + 2 * end) / 3 if distance(mid1) > distance(mid2): start = mid1 else: end = mid2 return distance(start) def distance(i): minX = ax * i + bx * (1 - i) minY = ay * i + by * (1 - i) kangX = cx * i + dx * (1 - i) kangY = cy * i + dy * (1 - i) return ((kangX - minX) ** 2 + (kangY - minY) ** 2) ** 0..
n, m, k = map(int, input().split()) result = 0 while True: n -= 2 m -= 1 if n < 0 or m < 0 or (n+m) < k: break result += 1 print(result)
people = int(input()) times = list(map(int, input().split())) result = 0 times.sort() for i in range(people): for j in range(i+1): result += times[j] print(result)
meeting = int(input()) times = [[0]*2 for _ in range(meeting)] for i in range(meeting): start, end = map(int, input().split()) times[i][0] = start times[i][1] = end times.sort(key=lambda x: (x[1], x[0])) result = 1 endTime = times[0][1] for i in range(1, meeting): if times[i][0] >= endTime: result += 1 endTime = times[i][1] print(result)
dy, dx = map(int, input().split()) if dy == 1: print(1) elif dy == 2: print(min(4, (dx+1)//2)) else: if dx
findNumber = list(input()) findNumber.sort(reverse=True) total = 0 if '0' not in findNumber: print(-1) else: for i in findNumber: total += int(i) if total % 3 != 0: print(-1) else: print(''.join(findNumber)) findNumber = list(input()) findNumber.sort(reverse=True) total = 0 for i in findNumber: total += int(i) if '0' not in findNumber or total % 3 != 0: print(-1) else: print(''.join(findNumber))
kindOfCoin, makeMoney = map(int, input().split()) coinList = [] for _ in range(kindOfCoin): coinList.append(int(input())) result = 0 for i in range(kindOfCoin-1, -1, -1): if makeMoney == 0: break if coinList[i] > makeMoney: continue result += makeMoney // coinList[i] makeMoney %= coinList[i] print(result)
import sys input = sys.stdin.readline n, c = map(int, input().split()) housePosition = [] for _ in range(n): housePosition.append(int(input())) housePosition.sort() def binary_search(housePosition, start, end): while start = install + middle: install = housePosition[i] installCount += 1 if installCount >= c: global result start = middle + 1 result = middle else: end = middle - 1 start = 1 end = ..
import sys a, b = map(int, sys.stdin.readline().split()) aList = list(map(int, sys.stdin.readline().split())) bList = list(map(int, sys.stdin.readline().split())) resultList = sorted(aList+bList) print(*resultList)
import sys ohLan, needLan = map(int, sys.stdin.readline().split()) ohLanList = [] # 오영식이 가지고 있는 랜선 리스트 for _ in range(ohLan): ohLanList.append(int(sys.stdin.readline())) start, end = 1, max(ohLanList) # 가장 작은 값, 리스트에서 가장 큰 값 while start = needLan: # 랜선의 개수가 분기점 start = middle + 1 else: end = middle - 1 print(end)