Problem:


Score : 200 points

Problem Statement

A group of people played a game. All players had distinct scores, which are positive integers.

Takahashi knows N facts on the players' scores. The i-th fact is as follows: the A_i-th highest score among the players is B_i.

Find the maximum possible number of players in the game.

Constraints

1 \leq N \leq 10^5

1 \leq A_i \leq 10^9(1\leq i\leq N)

0 \leq B_i \leq 10^9(1\leq i\leq N)

If i ≠ j, A_i ≠ A_j.

There exists a possible outcome of the game that are consistent with the facts.

All input values are integers.

Inputs

Input is given from Standard Input in the following format:

N
A_1 B_1
:
A_N B_N

Outputs

Print the maximum possible number of players in the game.

Sample Input 1

3
4 7
2 9
6 2

Sample Output 1

8

The maximum possible number of players is achieved when, for example, the players have the following scores: 12,9,8,7,5,2,1,0.

Sample Input 2

5
1 10
3 6
5 2
4 4
2 8

Sample Output 2

7

Sample Input 3

2
1 1000000000
1000000000 1

Sample Output 3

1000000001



Sample input:
3
4 7
2 9
6 2


Sample output:
8

Submission status: Accepted

Solution code:
# Tenka1 Programmer Beginner Contest 2017: B – Different Distribution
N = int(input())
A, B = [], []
for _ in range(N):
    tmp = input().split()
    A.append(int(tmp[0]))
    B.append(int(tmp[1]))

idx = A.index(max(A))

print(A[idx] + B[idx])

Submission status: Accepted

Solution code:
n = int(input())
num = 0
ans = 0
for i in range(n):
    a,b = map(int,input().split())
    if a >= num:
        num = a
        ans = b
print(num+ans)

Submission status: Accepted

Solution code:
N=int(input())
A=[0]*N
B=[0]*N
for i in range(N) :
  A[i],B[i]=map(int,input().split())
print(max(A)+min(B))

Submission status: Accepted

Solution code:
N = int(input())
x = 0
ans = 0
for _ in range(N):
    A, B = map(int, input().split())
    if A > x:
        x = A
        ans = B
print(x+ans)

Submission status: Accepted

Solution code:
n=int(input())
ab=[list(map(int, input().split())) for _ in range(n)]
for i in range(n):
    ab[i][1]*=-1
ab.sort()

ans=0

for i in range(n-1):
    ans+=min(ab[i+1][0]-ab[i][0],ab[i+1][1]-ab[i][1])
print(ans+ab[0][0]-ab[-1][1])

Submission status: Accepted

Solution code:
n = int(input())

x,y=-1,0
for i in range(n):
    a,b = map(int,input().split())
    if a>x:
        x=a
        y=b

print(x+y)

Submission status: Accepted

Solution code:
n = int(input())
a, b = sorted([tuple(map(int, input().split())) for _ in range(n)])[::-1][0]
print(a + b)

Submission status: Accepted

Solution code:
n = int(input())
ab = [tuple(map(int, input().split())) for _ in range(n)]

ab.sort()
ans = ab[0][0] + ab[-1][1] + (ab[-1][0] - ab[0][0])
print(ans)

Submission status: Accepted

Solution code:
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N = I()
X = [tuple(MI()) for _ in range(N)]
X.sort()
print(sum(X[-1]))

Submission status: Accepted

Solution code:
n = int(input())
ab = [tuple(map(int, input().split())) for _ in range(n)]

ab.sort()
ans = ab[0][0] + ab[n - 1][1] + (ab[n - 1][0] - ab[0][0])
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
ab = [tuple(map(int, input().split())) for _ in range(N)]
ab.sort(key=lambda x: x[0])
ans = ab[-1][0] + ab[-1][1]
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]

x = min([j for i,j in L])

for i,j in L:
    if j == x:
        print(i+j)
        break

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A =[]
    B =[]
    for i in range(N):
        a,b = map(int,input().split())
        A.append(a)
        B.append(b)
    A.sort()
    B.sort(reverse = True)
    #print(A,B)
    #１を求めるよ
    ans = 0
    ans += len(A)
    for i in range(len(A)-1):
        ans += A[i+1] - A[i] - 1
    #3を求めるよ
    ans += B[len(A)-1]
    #2を求めるよ
    tmp = A[0]-1
    #if B[0]+tmp > 1000000000:
        #ans += 1000000000 - B[0]
    #else:
    ans += tmp

    return ans

print(main())

Submission status: Accepted

Solution code:
n=int(input())
m=0
ans=0
for i in range(n):
    a,b=map(int,input().split())
    if a>m:
        m=a
        ans=a+b
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
abl = [tuple(map(int, input().split())) for _ in range(n)]
abl.sort()

a_max = abl[-1][0]
b_min = abl[-1][1]
ans = a_max + b_min
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = []
b = []
for i in range(n):
    s,t = map(int,input().split())
    a.append(s)
    b.append(t)
print(max(a)+min(b))

Submission status: Accepted

Solution code:
def LI():
    return list(map(int, input().split()))


N = int(input())
ansA = 0
ansB = 0

for _ in range(N):
    A, B = LI()
    if ansA > A:
        continue
    ansA = A
    ansB = B
print(ansA+ansB)

Submission status: Accepted

Solution code:
N = int(input())

member = {}
min_score = 10**9
for i in range(N):
    a, b = [int(x) for x in input().split()]
    member[b] = a

    if min_score > b:
        min_score = b

last = member[min_score]
print(last + min_score)

Submission status: Accepted

Solution code:
n = int(input())

ab = []
for _ in range(n):
    a, b = map(int, input().split())
    ab.append((b, a))
    
ab.sort()

print(ab[0][0] + ab[0][1])

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    N = int(input())
    AB = []
    for _ in range(N):
        ai, bi = map(int, input().split())
        AB.append((ai, bi))
    AB = sorted(AB, key=lambda x: x[0])
    ans = AB[0][0] - 1
    for i in range(N - 1):
        diff = AB[i + 1][0] - AB[i][0]
        ans += diff
    ans += AB[-1][1] + 1
    print(ans)    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
am,bm=0,10**9
for i in range(n):
    a,b=map(int,input().split())
    am=max(am,a)
    bm=min(bm,b)
print(am+bm)

Submission status: Accepted

Solution code:
N = int(input())

AB = [list(map(int,input().split())) for _ in range(N)]

AB.sort(reverse=True)

print(sum(AB[0]))

Submission status: Accepted

Solution code:
N = int(input())
A = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[0])
a,b = A[-1]
print(a+b)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N = I()
X = [tuple(MI()) for _ in range(N)]
X.sort()
print(sum(X[-1]))

Submission status: Accepted

Solution code:
N = int(input())
bmin = 10000000000
ans = 0
for i in range(N):
    a,b = map(int,input().split())
    if b < bmin:
        bmin = b
        ans = a + bmin
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ABs = [tuple(map(int, input().split())) for _ in range(N)]

A, B = min(ABs, key=lambda t: t[1])
print(A + B)

Submission status: Accepted

Solution code:
N = int(input()); INF = float("inf")
A = INF
for i in range(N):
  a,b = map(int,input().split())
  A = min(A,(a+b))
print(A)

Submission status: Accepted

Solution code:
N = int(input())
AB = [tuple(map(int,input().split())) for i in range(N)]
a,b = max(AB)
print(a+b)

Submission status: Accepted

Solution code:
N = int(input())
mini1 = 0
mini2 = 0
for i in range(N):
  MM = input().split()
  a = int(MM[0])
  b = int(MM[1])
  if a > mini1:
    mini1 = a
    mini2 = b
    
print(mini1 + mini2)

Submission status: Accepted

Solution code:
n=int(input())
t=0
ans=0
for i in range(n):
    a,b=map(int,input().split())
    if t<a:
        ans=a+b
        t=a
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = [0]*n
for i in range(n):
    a[i] = list(map(int,input().split()))
a.sort(key= lambda val : val[0],reverse=True)
print(a[0][0] + a[0][1])

Submission status: Accepted

Solution code:
N = int(input())
info = []
for i in range(N):
    b, a = map(int, input().split())
    info.append((a, b))
# print(info)
info.sort()

# print(info)
ans = sum(info[0])
print(ans)

Submission status: Accepted

Solution code:
import sys, math
from collections import deque

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    A, B = i2(N)
    print(min(B)+max(A))
        

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
AB=[]
for i in range(N):
    AB.append(list(map(int,input().split())))
a=AB[0][1]
b=0
for i in range(1,N):
    if AB[i][1]<a:
        a=AB[i][1]
        b=i
print(a+AB[b][0])

Submission status: Accepted

Solution code:
n = int(input())
l = [list(map(int, input().split())) for i in range(n)]
l.sort(key=lambda x: x[0])
print(l[-1][0] + l[-1][1])

Submission status: Accepted

Solution code:
'''
Created on 2020/08/20

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  ans=0
  pre=0
  for _ in [0]*N:
    A,B=map(int,pin().split())
    if ans<A:
      ans=A 
      pre=B 
  print(ans+pre)
  return 

main()

Submission status: Accepted

Solution code:
n = int(input())
a, b = [0] * n, [0] * n
for i in range(n):
  a[i], b[i] = map(int, input().split())
x = a.index(max(a))
print(a[x] + b[x])

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rf = lambda: map(float, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
min_ = inf
for _ in range(n):
    min_ = min(min_, sum(rm()))
print(min_)

Submission status: Accepted

Solution code:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    AB = []
    for _ in range(N):
        a, b = map(int, input().split())
        AB.append((a, b))
    AB.sort(key=lambda x: x[0])
    print(AB[-1][0] + AB[-1][1])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
minv = 1e9+1
min_idx = -1
for i in range(n):
    a, b = map(int, input().split(' '))
    if b < minv:
        minv = b
        min_idx = a
print(min_idx+minv)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    AB = list(list(map(int, readline().split())) for _ in range(N))
    ans = max(AB)[0] + max(AB)[1]
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
a = []
b = []
for i in range(n):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)

i = a.index(max(a))
print(max(a)+b[i])

Submission status: Accepted

Solution code:
n = int(input())
ab = []
for i in range(n):
    ab.append(list(map(int, input().split())))
ab.sort()
print(ab[-1][0] + ab[-1][1])

Submission status: Accepted

Solution code:
n = int(input())
L = []
for i in range(n):
    a,b = map(int,input().split())
    L.append((a,b))
L.sort()

max_zyun = L[0][0]
min_score = L[-1][1]

cnt = n + max_zyun-1 + min_score

for i in range(n-1):
    cnt +=(min(L[i+1][0] - L[i][0] -1,L[i][1] - L[i+1][1]-1))

print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
a,b=10**9,10**9
for i in range(n):
    at,bt=map(int,input().split())
    if bt<=b:
        a,b=at,bt
print(a+b)

Submission status: Accepted

Solution code:
n=int(input())
a,b=10**9,10**9
for i in range(n):
    at,bt=map(int,input().split())
    if bt<=b:
        a,b=at,bt
print(a+b)

Submission status: Accepted

Solution code:
# Tenka1_2017_B_Different_Distribution.py

N = int(input())
I = []*N
for i in range(N):
    a, b = list(map(int, input().split()))
    I.append((a, b))
# print(I)
I.sort()
k = I[0][0]
l = I[-1][0]
m = I[-1][1]
# print(k,l,m)
print((k-1)+(l-k+1)+m)

Submission status: Accepted

Solution code:
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
A.sort()
print(sum(A[-1]))

Submission status: Accepted

Solution code:
import collections


def main():
    n = int(input())
    abList = [0] * n
    for i in range(n):
        abList[i] = list(map(int, input().split()))
    abList.sort(key=lambda x: x[0], reverse=True)
    print(sum(abList[0]))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    BA = []
    for _ in range(N):
        A, B = LI()
        BA.append((B, A))

    BA.sort()
    ans = BA[0][0] + BA[0][1]
    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
n = int(input())
l = sorted([list(map(int, input().split())) for i in range(n)])[::-1]
ans = l[0][0] + l[0][1]
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
max_a=0
point=0
for _ in range(N):
  A,B=map(int,input().split())
  if max_a<A:
    max_a=A
    point=B
print(max_a+point)

Submission status: Accepted

Solution code:
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[0])
print(ab[-1][0]+ab[-1][1])

Submission status: Accepted

Solution code:
N = int(input())
li = [[int(i) for i in input().split()] for _ in range(N)]

li.sort(reverse=True)
print(sum(li[0]))

Submission status: Accepted

Solution code:
n = int(input())
max_value = -1
diff_between_0 = 0

for _ in range(n):
  a, b = [int(x) for x in input().split()]
  if max_value < a:
    max_value = a
    diff_between_0 = b

print(max_value + diff_between_0)

Submission status: Accepted

Solution code:
N = int(input())
M = 0
m = 10**9
c = 0
for i in range(N):
  a,b = map(int,input().split())
  if m >= a:
    m = a
  if M < a:
    M = a
    c = b + 1
ans = c+M-1
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

N = int(input())

max_a = 0
res = 0

for _ in range(N):
    a, b = map(int, input().split())
    if max_a < a:
        max_a = a
        res = a + b

print(res)

Submission status: Accepted

Solution code:
# coding: utf-8

N = int(input())
L = []
p1 = 0
p2 = float('inf')
r1 = float('inf')
r2 = 0
for i in range(N):
    a, b = map(int,input().split())
    L.append([a, b])
    r1 = min(a, r1)
    p1 = max(b, p1)
    r2 = max(a, r2)
    p2 = min(b, p2)

ans = r2
for i in range(N):
    if L[i][0] == r2:
        ans += L[i][1]
print(ans)

Submission status: Accepted

Solution code:
import sys
readline=sys.stdin.readline
read=sys.stdin.read

n=int(readline())
p=[list(map(int,lst.split())) for lst in read().splitlines()]
e=max(p, key=lambda x:x[0])
print(e[0]+e[1])

Submission status: Accepted

Solution code:
N = int(input())
maxi = 0
ans = 0
for i in range(N):
  A, B = map(int, input().split())
  if maxi < A:
    maxi = A
    ans = A + B
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
max_a = 1
max_v = -1
for _ in range(N):
  a, b = [int(i) for i in input().split()]
  if max_a <= a:
    max_a = a
    max_v = b
print(max_a + max_v)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
maxA = 0
for i in range(N):
  A, B = map(int,input().split())
  if A > maxA: 
    maxA = A
    ans = A + B
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a,b = [],[]
for i in range(n):
  aa, bb = map(int, input().split())
  a.append(aa)
  b.append(bb)

print (max(a)+min(b))

Submission status: Accepted

Solution code:
N=int(input())

minarg_A=0
min_B=float("inf")
for _ in range(N):
  A,B=map(int,input().split())
  if B<min_B:
    min_B=B
    minarg_A=A
#print(minarg_A,min_B)

print(minarg_A+min_B)

Submission status: Accepted

Solution code:
n=int(input())
ma,r=0,0
for _ in range(n):
    a,b=map(int,input().split())
    if ma<a:
        ma=a
        r=ma+b
print(r)

Submission status: Accepted

Solution code:
n = int(input())
ma = 0
value = 0
for i in range(n):
    a, b = map(int, input().split())
    if a > ma:
        ma = a
        value = b

print(ma + value)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union
# import time
# import math, cmath
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import _heapify_max, _heappop_max, _siftdown_max
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import Fraction               # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10)



def main():
    Num = Union[int, float]
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79e+308
    # inf = 2 ** 63 - 1             # (for fast JIT compile in PyPy) 9.22e+18
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input():  return sys.stdin.readline().rstrip()
    def ii():     return int(input())
    def isp():    return input().split()
    def mi():     return map(int, input().split())
    def mi_0():   return map(lambda x: int(x)-1, input().split())
    def lmi():    return list(map(int, input().split()))
    def lmi_0():  return list(map(lambda x: int(x)-1, input().split()))
    def li():     return list(input())
    def debug(x): print(x, file=sys.stderr)
    # def _heappush_max(h, item): h.append(item); _siftdown_max(h, 0, len(h)-1)
    
    
    n = ii()
    A = []
    B = []
    for _ in range(n):
        a, b = mi()
        A.append(a)
        B.append(b)
    M = max(A)
    ind = A.index(M)
    print(M + B[ind])



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a = int(input())
l =[]
for i in range(a):
    s = input().split(" ")
    n = int(s[0]); m = int(s[1])
    l.append(m+n)
print(min(l))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
ab = [LI() for _ in range(n)]
ab.sort(key = itemgetter(1))
print(sum(ab[0]))

Submission status: Accepted

Solution code:
n = int(input())
min_a = 10**9+1
min_s = 0
max_a = 0
max_s = 0
for i in range(n):
  a,b = map(int, input().split())
  if a<min_a:
    min_a = a
    min_s = b
  if a>max_a:
    max_a = a
    max_s = b

cnt = max_a
cnt += max_s
print(cnt)

Submission status: Accepted

Solution code:
AB = []
for _ in range(int(input())):
    a, b = map(int, input().split())
    AB.append([a, b])

AB = sorted(AB, key=lambda x: x[0], reverse=True)
print(sum(AB[0]))

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n = k()
a = [l() for j in range(n)]
a.sort()
x = a[-1][1]+a[-1][0]
print(x)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    temp=0
    ans=0
    for i in range(N):
        a,b=MI()
        if a>temp:
            ans=a+b
            temp=a
            
    print(ans)

main()

Submission status: Accepted

Solution code:
n = int(input())
saigo = 0
ans = 0
for _ in range(n):
    a,b = map(int,input().split())
    if saigo < a:
        saigo = a
        ans = a + b

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
info = []
mi = float('inf')
ma = 0
for _ in range(n):
  a,b = map(int, input().split())
  ma = max(ma, a)
  mi = min(mi,b)
print(ma+mi)

Submission status: Accepted

Solution code:
N = int(input())
a, b = [], []
for i in range(N):
    a0, b0 = map(int, input().split())
    a.append(a0)
    b.append(b0)
a, b = zip(*sorted(zip(a, b)))
ans = a[-1]+b[-1]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = [list(map(int,input().split())) for i in range(n)]
a,b = [list(i) for i in zip(*l)]
m = a.index(max(a))
print(a[m] + b[m])

Submission status: Accepted

Solution code:
N=int(input())
dic=dict()
for _ in range(N):
  a,b=map(int,input().split())
  dic[a]=b

dic=sorted(dic.items(),key=lambda x:x[0])

ans= dic[-1][0] + dic[-1][1]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
max_a = 0
st_b = 0
for i in range(n):
    a,b = map(int,input().split())
    if max_a < a:
        max_a = a
        st_b = b
print(max_a+st_b)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
now = -1
for i in range(n):
  a,b = map(int,input().split())
  if a > now:
    now = a
    ans = a + b

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    A = [None] * N
    B = [None] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())
    print(max(A)+B[A.index(max(A))])

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())
x=[list(map(int,input().split())) for i in range(n)]
y=0
z=0
for i in x:
    a,b=i[0],i[1]
    if y<a:
      y=a
      z=b
print(y+z)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    A = []
    for _ in range(n):
        a, b = list(map(int, input().split()))
        A.append([a, b])
    A.sort(key = lambda x: x[0], reverse = True)
    print(sum(A[0]))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
INF = 1001001001

n = int(input())

a_max = -1
b_min = INF
for i in range(n):
    a, b = map(int, input().split())
    if b_min > b:
        a_max = a
        b_min = b

ans = a_max + b_min
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

mini = [10 ** 10, -1]
for _ in range(N):
    a, b = map(int, input().split())
    if mini[0] > b:
        mini[0] = b
        mini[1] = a

print(mini[1] + mini[0])

Submission status: Accepted

Solution code:
n = int(input())
a = []
b = []
for i in range(n):
    x,y = map(int,input().split())
    a.append(x)
    b.append(y)

s = a.index(max(a))
print(max(a)+b[s])

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(n):
  a.append(list(map(int, input().split())))
a.sort(reverse=True)
print(a[0][0] + a[0][1])

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
AB = [LIST() for _ in range(N)]
AB.sort(key = lambda x: x[0])
print(AB[-1][0] + AB[-1][1])

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
AB = [LIST() for _ in range(N)]

AB.extend([[0, INF], [INF, 0]])

AB.sort(key = lambda x:x[0])

ans = 0
for i in range(1, N+2):
	ans += min(AB[i][0]-AB[i-1][0], AB[i-1][1]-AB[i][1])

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
amax, score = 0, 0
for _ in range(N):
    a, b = map(int, input().split())
    if amax < a:
        amax = a
        score = b
ans = amax + score
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = []
B = []
for i in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
print(max(A)+B[A.index(max(A))])

Submission status: Accepted

Solution code:
N=int(input())
ab=[list(map(int,input().split()))for _ in range(N)]

ab.sort()
ans=ab[-1][0]+ab[-1][1]
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
AB = sorted([list(map(int, stdin.readline().rstrip().split())) for _ in range(N)])
print(AB[N-1][0]+AB[N-1][1])

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    a = int(input())
    max1 = 0
    max2 = 0
    for i in range(a):
        b, c = map(int, input().split())
        if max1<b:
            max1=b
            max2=c
    print(max1+max2)

Submission status: Accepted

Solution code:
N = int(input())

A_list = list()
B_list = list()

for i in range(N):
    A,B = map(int, input().split())
    A_list.append(A)
    B_list.append(B)

print(min(A_list)-1 + max(A_list)-min(A_list)+1 +min(B_list))

Submission status: Accepted

Solution code:
n = int(input())
A = []
B = []
for i in range(n):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
ind = A.index(max(A))
print(max(A)+B[ind])

Submission status: Accepted

Solution code:
n = int(input())
x = [list(map(int, input().split())) for _ in range(n)]
x.sort(key=lambda x:x[0])
worst = x[-1]

print(worst[0] + worst[1])