N = int(input())
arr = []
total_person = 0
for _ in range(N):
town,person = map(int,input().split())
total_person += person
arr.append([town,person])
arr.sort()
person_list = [k[1] for k in arr]
start = 0
ends = N -1
answer = float('inf')
while start <= ends:
mid = (start+ends)//2
left = sum(person_list[:mid+1])
right = total_person - left
if left >= right:
answer = min(arr[mid][0],answer)
ends = mid - 1
else:
start = mid + 1
print(answer)
import sys
input = sys.stdin.readline
N = int(input())
total_person = 0
arr = []
for _ in range(N):
town,person = map(int,input().split())
total_person += person
arr.append([town,person])
arr.sort()
left_person = 0
ind = 0
while left_person < total_person/2:
left_person += arr[ind][1]
ind += 1
print(arr[ind-1][0])
'알고리즘 > 백준_복기_미완료' 카테고리의 다른 글
[BOJ/백준] 2122 센서 (0) | 2021.05.02 |
---|---|
[BOJ/백준] 2156 포도주 시식 (0) | 2021.05.02 |
[BOJ/백준] 2098 외판원 순회 (0) | 2021.05.02 |
[BOJ/백준] 2031 이 쿠키 달지 않아! (0) | 2021.05.02 |
[BOJ/백준] 1949 우수 마을 (0) | 2021.05.02 |