#54208: 福利網站統整


yp11331059@yphs.tp.edu.tw (Wajk)


n = int(input())
e_s = 0
t_p = 0
t_m = 0
t = []
s = []
for _ in range (n):
    t1,s1 = list(map(int,input().split()))
    t.append(t1)
    s.append(s1)
for __ in range (n):
    if s[__] == -1:
        t_m += 1
t_p = max(s) - len(t) - 2*t_m
if t_p < 0:
    t_p = 0
print(t_p, end = " ")
print(t[s.index(max(s))])

#54209: Re: 福利網站統整


yp11331059@yphs.tp.edu.tw (Wajk)


此處為python解答