Problem:


ウォーキング

会津リバーサイドホスピタルでは、リハビリと健康増進のため、入院患者が一日二回のウォーキングを行っています。元気に退院するために、ウォーキングで体力を回復しようと頑張る人が日に日に増えきたことから、院長が「一日で一番長い距離を歩いた人にプレゼントをあげよう!」という企画を立ち上げました。

  患者の数 n (1 ≤ n ≤ 10000)、それぞれの患者の番号 pi (1 ≤ pi ≤ 10000)、一回目に歩いた距離 d1i、二回目に歩いた距離 d2i (0 ≤ d1i, d2i ≤ 5000) を入力とし、歩いた距離の合計が最も長い患者の番号とその距離を出力するプログラムを作成してください。ただし、一日に歩いた距離が同じ患者はいないものとします。

Input

複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。
各データセットは以下の形式で与えられます。

n
p1 d11 d21
p2 d12 d22
:
pn d1n d2n

入力はすべて整数で与えられます。データセットの数は50 を超えません。

Output

入力データセットごとに、最も長い合計距離を歩いた患者の番号とその歩いた距離を１行に出力します。

Sample Input

5
263 2345 2504
1 3210 1985
5000 1501 4132
10000 503 3107
51 1758 2690
3
345 5000 2396
7 3910 1590
6789 2525 3616
0

Output for the Sample Input

5000 5633
345 7396



Sample input:
5
263 2345 2504
1 3210 1985
5000 1501 4132
10000 503 3107
51 1758 2690
3
345 5000 2396
7 3910 1590
6789 2525 3616
0


Sample output:
5000 5633
345 7396

Submission status: Accepted

Solution code:
while(True):
    n = int(input())
    if not n: break
    maxind = 0
    maxnum = 0
    for _ in range(n):
        a,b,c = map(int,input().split())
        if maxnum < b+c: maxind=a; maxnum=b+c
    print(maxind,maxnum)

Submission status: Accepted

Solution code:
while 1:
    n = int(input())
    if n == 0:break
    md = [0,0,0]
    for i in range(n):
        p = list(map(int,input().split()))
        if md[1]+md[2] < p[1]+p[2]:
            md = p
    print(md[0],str(md[1]+md[2]))

Submission status: Accepted

Solution code:
import sys
f = sys.stdin

import operator

while True:
    n = int(f.readline())
    if n == 0:
        break
    pd = [map(int, f.readline().split()) for _ in range(n)]
    pd = [[p, d1 + d2] for p, d1, d2 in pd]
    pd.sort(key=operator.itemgetter(1))
    print(*pd[-1])

Submission status: Accepted

Solution code:
while True:
    n = int(raw_input())
    if n == 0: break
    num = 0
    d = 0
    for i in range(n):
        p, d1, d2 = map(int, raw_input().split())
        if d < d1+d2:
            num = p
            d = d1+d2
    else:
        print num, d

Submission status: Accepted

Solution code:
while True:
    data = {}
    n = input()
    if n == 0:
        break
    for i in range(n):
        tmp = raw_input()
        tmp_data = tmp.split(" ")
        if i == 0:
            data.update({tmp_data[0] : int(tmp_data[1]) + int(tmp_data[2])})
        else:
            flag = False
            for j in data.iterkeys():
                if data[j] < int(tmp_data[1]) + int(tmp_data[2]):
                    flag = True
                if flag:
                    data.clear()
                    data.update({tmp_data[0] : int(tmp_data[1]) + int(tmp_data[2])})

    for key in data.iterkeys():
        print "%s %d" % (key, data[key])

Submission status: Accepted

Solution code:
while 1:
    n=int(input())
    if n==0:break
    a=[map(int, input().split()) for _ in range(n)]
    a=[[p,d1+d2] for p, d1, d2 in a]
    a.sort(key=lambda b:b[1])
    print(*a[-1])

Submission status: Accepted

Solution code:
from operator import itemgetter as I
while True:
    n= int(input())
    if n==0: break
    d=dict()
    for _ in range(n):
        p,d1,d2= map(int, input().split())
        d[p]= d1+d2
    print(*sorted(d.items(), key=I(1))[-1])

Submission status: Accepted

Solution code:
# Aizu Problem 0217: Walking in the Hospital

import sys, math, os, fractions

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    n = int(input())
    if n == 0:
        break
    high = 0
    for _ in range(n):
        no, w1, w2 = [int(__) for __ in input().split()]
        w = w1 + w2
        if w > high:
            high = w
            patient = no
    print(patient, high)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break

    patients = []
    for _ in range(n):
        p, d1, d2 = map(int, input().split())
        patients.append((p, d1+d2))
    print(*max(patients, key=lambda x: x[1]))

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break

    patients = [map(int, input().split()) for _ in range(n)]
    patients = [(p, d1+d2) for p, d1, d2 in patients]
    print(*max(patients, key=lambda x: x[1]))

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    arr = []
    for i in range(n):
        tmp = list(map(int, input().split()))
        arr.append([tmp[0], tmp[1] + tmp[2]])
    arr.sort(key = lambda x: x[1], reverse=True)
    print("{} {}".format(arr[0][0], arr[0][1]))

Submission status: Accepted

Solution code:
# AOJ 0217 Walking in the Hospital
# Python3 2018.6.23 bal4u

while 1:
	n = int(input())
	if n == 0: break
	dmax = 0
	for i in range(n):
		p, d1, d2 = map(int, input().split())
		if d1+d2 > dmax: id, dmax = p, d1+d2
	print(id, dmax)

Submission status: Accepted

Solution code:
while True:
  n = int(input())
  if n == 0:
    break
  lst = []
  for _ in range(n):
    p, d1, d2 = map(int, input().split())
    lst.append((d1 + d2, p))
  lst.sort()
  print(lst[-1][1], lst[-1][0])

Submission status: Accepted

Solution code:
while True:
    try:
        n=input()
        if n==0:break
        m=0
        dic={}
        for i in range(n):
            p,d1,d2=map(int,raw_input().split())
            t=d1+d2
            m=max(m,t)
            dic[t]=p
        print dic[m],m
    except SyntaxError:
        pass

Submission status: Accepted

Solution code:
import sys
def main():
    while True:
        ipt=raw_input()
        if str.isdigit(ipt):
            n=int(ipt)
            if n==0:    break;
            solve(n)
        else:
            sys.stderr.write(ipt)
def solve(n):
    a=[]
    for _ in range(n):
        tmp=map(int,raw_input().split(" "))
        a.append(Pair(tmp[0],tmp[1]+tmp[2]))
    a.sort()
    print a[-1].x, a[-1].y
class Pair:
    def __init__(self,x,y):
        self.x=x
        self.y=y
    def __cmp__(self,a):
        return self.y-a.y
if __name__=="__main__":    main()

Submission status: Accepted

Solution code:
while 1:
    try:
        n = input()
        if n==0: break
        l = []
        for i in range(n):
            p,d1,d2 = map(int, raw_input().split())
            l.append([p,d1+d2])
        l.sort(reverse=True, key=lambda x:x[1])
        print l[0][0],l[0][1]
    except SyntaxError:
        pass

Submission status: Accepted

Solution code:
while 1:
    try:
        n=input()
        if n==0:break
        l=m=0
        for i in [1]*n:
            p,d1,d2=map(int,raw_input().split())
            d=d1+d2
            if d>m:l,m=p,d
        print l,m
    except SyntaxError:
        pass

Submission status: Accepted

Solution code:
while True:
    N=int(input())
    if N==0: break
    P=[[int(i) for i in input().split()]for _ in range(N)]
    P.sort(key=lambda x: x[1]+x[2])
    print(P[-1][0],P[-1][1]+P[-1][2])

Submission status: Accepted

Solution code:
while 1:
    n = int(input())
    if n == 0:
        break
    L = []
    for i in range(n):
        p,d1,d2  = map(int,input().split())
        L.append((p,d1+d2))

    L.sort(key = lambda x :-x[1])
    print(L[0][0],L[0][1])

Submission status: Accepted

Solution code:
while 1:
    n = int(input())
    if n == 0:
        break
    x = {}
    for i in range(n):
        p,d1,d2 = map(int,input().split())
        v = d1 + d2
        x[p] = v
    x = sorted(x.items(), key=lambda x:x[1])
    print(f'{x[n-1][0]} {x[n-1][1]}')

Submission status: Accepted

Solution code:
while True :
    n = int(input())
    if n == 0 :
        break
    max_d = 0
    max_p = 0
    for i in range(n) :
        p, a, b = map(int, input().split())
        if max_d < (a + b) :
            max_d = a + b
            max_p = p
    print(max_p, max_d)

Submission status: Accepted

Solution code:
while True:
    hosuu = {}
    hosu = []
    i = int(input())
    if i == 0:
        break
    else:
        for num in range(i):
            a,b,c = input().split(" ")
            num1 = int(b) + int(c)
            a = int(a)
            hosuu[num1] = a
            hosu.append(num1)
        hosu.sort()
        hosu.reverse()
        print(str(hosuu[hosu[0]]) + " " + str(hosu[0]))

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    ls = []
    for i in range(n):
        v = list(map(int,input().split()))
        ls.append((sum(v[1:]),v[0]))
    ls.sort()
    ls.reverse()
    print(ls[0][1],ls[0][0])

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    walk = []
    for i in range(n):
        p,d1,d2 = map(int,input().split())
        walk.append([d1+d2,p])
    walk.sort(reverse = True)
    print(walk[0][1],walk[0][0])

Submission status: Accepted

Solution code:
while True:
    num = int(input())
    if num == 0:
        break
    
    m = 0
    mp = None
    for _ in range(num):
        p, d1, d2  = [int(x) for x in input().split()]
        if d1 + d2 > m:
            m = d1 + d2
            mp = p
    print(mp,m)

Submission status: Accepted

Solution code:
while True:
    N=int(input())
    if N== 0:
        break
    B=0
    V=0
    for i in range(N):
        p,d,g=map(int,input().split())
        S=d+g
        if S>V:
            V=S
            B=p
    print(B,V)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n==0: break
    km= 0
    for i in range(n):
        p,d1,d2 = map(int,input().split())
        m = d1 +d2
        if km < m:
            km = m
            a = p
     
    print(a,km)

Submission status: Accepted

Solution code:
while True:
  n = int(input())
  if n == 0:
    break
  
  large = 0
  for _ in range(n):
    p, d1, d2 = map(int, input().split())
    if large < d1 + d2:
      large = d1 + d2
      number = p
      
  print(number, large)

Submission status: Accepted

Solution code:
while 1:
    n = int(input())
    if n == 0: break
    dmax = 0
    for i in range(n):
        p, d1, d2 = map(int, input().split())
        if d1+d2 > dmax: id, dmax = p, d1+d2
    print(id, dmax)

Submission status: Accepted

Solution code:
while 1:
  n = int(input())
  if n== 0: break
  dmax = 0
  for i in range(n):
      p, d1, d2 = map(int,input().split())
      if d1+d2>dmax:
        id,dmax=p,d1+d2
  print(id,dmax)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Walking in the Hospital
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0217

"""
import sys


def solve(n):
    result = sorted([[int(i) for i in input().split()] for _ in range(n)], key=lambda x: x[1]+x[2])
    return result[-1][0], sum(result[-1][1:])


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break
        ans = solve(n)
        print(*ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
while 1:
    n=int(input())
    if n==0:break
    top=0
    score=0
    for i in range(n):
        p,d1,d2=map(int,input().split())
        if score<d1+d2:
            top=p
            score=d1+d2
    print(top,score)

Submission status: Accepted

Solution code:
while 1:
    n = int(input())
    if n == 0:
        break

    large = 0
    for _ in range(n):
        p, d1, d2 = map(int, input().split())
        if large < d1 + d2:
            large = d1 + d2
            number = p

    print(number, large)

Submission status: Accepted

Solution code:
while True:
    N = int(input())
    if N == 0:
        break

    ans1 = -1
    ans2 = -1
    for i in range(N):
        p,d1,d2 = [int(j) for j in input().split()]
        if d1+d2 > ans2:
            ans1 = p
            ans2 = d1+d2
    print(ans1,ans2)

Submission status: Runtime Error

Solution code:
while True:
    n=input()
    if n==0:break
    D={}
    m=0
    for i in range(n):
        p,d1,d2=map(int,raw_input().split())
        t=d1+d2
        m=max(m,t)
        D[t]=p
    print D[m],m

Submission status: Runtime Error

Solution code:
while True:
    n=input()
    if n==0:break
    m=0
    dic={}
    for i in range(n):
       p,d1,d2=map(int,raw_input().split())
       t=d1+d2
       m=max(m,t)
       dic[t]=p
    print dic[m],m

Submission status: Runtime Error

Solution code:
def main():
    while True:
        n=int(raw_input())
        if n==0:    break;
        solve(n)
def solve(n):
    a=[]
    for _ in range(n):
        tmp=map(int,raw_input().split(" "))
        a.append(Pair(tmp[0],tmp[1]+tmp[2]))
    a.sort()
    print a[-1].x, a[-1].y
class Pair:
    def __init__(self,x,y):
        self.x=x
        self.y=y
    def __cmp__(self,a):
        return self.y-a.y
if __name__=="__main__":    main()

Submission status: Runtime Error

Solution code:
while 1:
    n = input()
    if n==0: break
    pm = -1; m = 0;
    for i in xrange(n):
        p,d1,d2 = map(int, raw_input().split())
        if m<d1+d2:
            pm = p; m = d1+d2;
    print pm,m

Submission status: Runtime Error

Solution code:
while 1:
    n = input()
    if n==0: break
    pm = -1; m = -1;
    for i in range(n):
        p,d1,d2 = map(int, raw_input().split())
        if m<d1+d2:
            pm = p; m = d1+d2;
    print pm,m

Submission status: Runtime Error

Solution code:
while 1:
    n = input()
    if n==0: break
    l = []
    for i in range(n):
        p,d1,d2 = map(int, raw_input().split())
        l.append([p,d1+d2])
    l.sort(reverse=True, key=lambda x:x[1])
    print l[0][0],l[0][1]

Submission status: Runtime Error

Solution code:
while 1:
	r={}
	n=input()
	if n==0:break
	for i in [1]*n:
		p,d1,d2=map(int,raw_input().split())
		r[p]=d1+d2
	a=max(r.items(),key=lambda x:x[1])
	print a[0],a[1]

Submission status: Runtime Error

Solution code:
while 1:
	try:
		r={}
		n=input()
		l=m=0
		for i in [1]*n:
			p,d1,d2=map(int,raw_input().split())
			d=d1+d2
			if d>m:l,m=p,d
		print l,m
	except syntaxError:
		pass

Submission status: Runtime Error

Solution code:
while 1:
	try:
		r={}
		n=input()
		l=m=0
		for i in [1]*n:
			p,d1,d2=map(int,raw_input().split())
			d=d1+d2
			if d>m:l,m=p,d
		print l,m
	except SyntaxError:
		pass