[Ch.7 - 이진 탐색] 부품 찾기
My code def binary_search(array, target, start, end): if start > end: return None mid = (start + end) // 2 if array[mid] == target: return mid elif array[mid] > target: return binary_search(array, target, start, mid - 1) else: return binary_search(array, target, mid + 1, end) n = int(input()) array = list(map(int,input().split())) array.sort() m = int(input()) needs = list(map(int,input().split(..
2022. 2. 15.
[Ch.6 - 정렬] 두 배열의 원소 교체
My code n, k = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) a.sort() b.sort() tmp = n for i in range(k): if a[i] < b[tmp-1]: a[i], b[tmp-1] = b[tmp-1], a[i] tmp -= 1 else: break print(sum(a)) Answer n, k = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) a.sort() b.sort(reverse = True) for i in range(..
2022. 2. 13.