import sys
input = sys.stdin.readline
N = int(input())
costs = [list(map(int, input().split())) for _ in range(N)]
costs.sort()
dp = [0] * N
max_profit = 0
answers = []
for i in range(N):
for j in range(i, N):
tmp = costs[i][0] - costs[j][1]
if tmp > 0:
dp[i] += tmp
if max_profit <= dp[i]:
if max_profit < dp[i]:
answers = []
max_profit = dp[i]
answers.append(costs[i][0])
print(min(answers) if answers else 0)
가격별로 이익값 비교
'practivceAlgorithm > 백준' 카테고리의 다른 글
[백준][Python] 9251 LCS (0) | 2021.12.15 |
---|---|
[백준][Python] 16953 A -> B (0) | 2021.12.07 |
[백준][Python] 2589 보물섬 (0) | 2021.11.15 |
[백준][Python] 17216 가장 큰 감소 부분 수열 (0) | 2021.11.09 |
[백준][Python] 16162 가희와 3단 고음 (0) | 2021.11.09 |