Problem:


Problem A: 期末試験!

私立桜が丘女子高等学校に通う平沢唯さんは明後日までに進路希望を出さなければならないのだが、困ったことに進路についてまだ何も決めていなかった。
友人の和に相談したところ、和の第一志望はK大と知り、自分もK大に入れるかどうか進路指導の先生に相談にいった。

相談された進路指導の先生であるあなたは唯さんがK大に入れるかどうかを予想するため唯さんの期末試験の成績を参考にすることにした。
しかし、唯さんは試験の山が当たるかどうかによって大きく成績が左右されるため、過去の期末試験の中で一番良かった時の点数と一番悪かった時の点数を調べることにした。
過去の期末試験のデータは5教科の各点数のみしか残っておらず、試験の合計点数は残っていなかった。
したがってあなたの仕事は各試験の点数データを入力として、過去の期末試験の中で一番良かった時の点数と一番悪かった時の点数を出力するプログラムを書くことである。

Input

n
s11 s12 s13 s14 s15
...
sn1 sn2 sn3 sn4 sn5

n は今までに受けた試験の回数である。試験の回数は1以上100以下である。
続く n 行には各試験における5教科の点数が与えられる。点数の範囲は0以上100以下の整数である。

Output

最高点 最低点を、一行に出力しなさい。最高点と最低点の間は1文字の空白で区切り、これら以外の文字を含んではならない。

Notes on Test Cases

上記入力形式で複数のデータセットが与えられます。各データセットに対して上記出力形式で出力を行うプログラムを作成して下さい。

n が 0 のとき入力の終わりを示します。

Sample Input

3
49 50 87 78 41
27 61 100 45 84
28 88 40 95 66
2
100 100 100 100 100
0 0 0 0 0
1
89 90 85 93 82
0

Output for Sample Input

317 305
500 0
439 439



Sample input:
3
49 50 87 78 41
27 61 100 45 84
28 88 40 95 66
2
100 100 100 100 100
0 0 0 0 0
1
89 90 85 93 82
0


Sample output:
317 305
500 0
439 439

Submission status: Wrong Answer

Solution code:
["{} {}".format(max(x), min(x)) for x in [[sum(map(int, input().split())) for _ in range(int(input()))]]]

Submission status: Wrong Answer

Solution code:
[print("{} {}".format(max(x), min(x))) for x in [[sum(map(int, input().split())) for _ in range(int(input()))]]]

Submission status: Accepted

Solution code:
while True:
  n = int(input())
  if n == 0:break
  lst = [sum(map(int, input().split())) for _ in range(n)]
  print(max(lst), min(lst))

Submission status: Accepted

Solution code:
while 1:
    n = input()
    if not n:
        break
    mi = 1000; ma = 0
    for i in xrange(n):
        s = sum(map(int, raw_input().split()))
        mi = min(mi, s)
        ma = max(ma, s)
    print ma, mi

Submission status: Accepted

Solution code:
while 1:
    n,a,b=int(input()),0,500
    if n==0:break
    for _ in range(n):
        s=sum(map(int,input().split()))
        a=max(a,s)
        b=min(b,s)
    print(a,b)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    
    [print("{} {}".format(max(x), min(x))) for x in [[sum(map(int, input().split())) for i in range(n)]]]

Submission status: Accepted

Solution code:
d = {0: lambda x, y: max(x, y),
     1: lambda x, y: min(x, y)}

while True:
    n = int(input())
    if n == 0:
        break
    ans = [0, 500]
    for _ in range(n):
        score = sum(map(int, input().split()))
        ans = [d[i](ans[i], score) for i in range(2)]
    print(*ans)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:break
    p = [sum(map(int, input().split())) for _ in range(n)]
    print("{} {}".format(max(p), min(p)))

Submission status: Accepted

Solution code:
while True:
  a = int(input())
  ans,x=[0]*a,0
  if a==0: break
  for i in range(a):
    hoge=map(int,raw_input().split())
    for i in range(5):
      ans[x]+=hoge[i]
    else: x+=1
  else: print max(ans),min(ans)

Submission status: Accepted

Solution code:
ans=[]
while True:
    scMax=0
    scMin=500
    n=input()
    if n==0:
        break
    for i in xrange(n):
        score=sum(map(int,raw_input().split()))
        if score > scMax:
            scMax=score
        if score < scMin:
            scMin=score
    ans.append(str(scMax)+' '+str(scMin))
    
for i in ans:
    print i

Submission status: Accepted

Solution code:
while True:
    n=input()
    if n==0:break
    mi,ma=501,0
    for i in range(n):
        s=sum(map(int,raw_input().split()))
        mi=min(s,mi)
        ma=max(s,ma)
    print "%d %d"%(ma,mi)

Submission status: Accepted

Solution code:
import sys

def solve():
    while True:
        n = int(raw_input())
	if n ==	0:
            return
	s = []
        for i in range(n):
            d =	map(int,raw_input().split())
            s.append(sum(d))
	print max(s),min(s)

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
while True:
    n = input()
    if n == 0:
        break
    L = [sum(map(int, raw_input().split())) for _ in xrange(n)]
    print "{} {}".format(max(L), min(L))

Submission status: Accepted

Solution code:
while 1:
	n = input()
	if n == 0: break
	s = [sum(map(int,raw_input().split())) for i in range(n)]
	print max(s),min(s)

Submission status: Accepted

Solution code:
#0が来るまで回数の入力を繰り返す
while True:
    j = int(input())
    if j == 0:break

    #点数を合計し、一番小さいかずと、一番大きい数を出力する
    else:
        num_list = []
        for _ in range(j):
            line = list(map(int,input().split()))
            num_list.append(sum(line))
        print(str(max(num_list)) + " " + str(min(num_list)))

Submission status: Accepted

Solution code:
while True :
    n = int(input())
    if n == 0 :
        break
    
    max_sum = 0
    min_sum = 500
    for i in range(n) :
        m_sum = 0
        m = list(map(int, input().split()))
        for j in range(5) :
            m_sum += m[j]
        if max_sum < m_sum :
            max_sum = m_sum 
        if min_sum > m_sum :
            min_sum = m_sum
        
    print(max_sum, min_sum)

Submission status: Accepted

Solution code:
while 1:
    n = int(input())
    if n == 0:
        break
    a = []
    for _ in range(n):
        a.append(sum(map(int, input().split())))
    print(max(a), min(a))

Submission status: Accepted

Solution code:
while 1:
    n = int(input())
    if n == 0:
        break
    total = []
    for i in range(n):
        score = input().split()
        sum = 0
        for s in score:
            sum += int(s)
        total.append(sum)
    print(max(total), min(total))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
while 1:
    n=int(input())
    if n==0:break
    s=[]
    for i in range(n):
        s.append(sum(map(int,input().split())))
    print(max(s),min(s))

Submission status: Accepted

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

    score = list(map(int, input().split()))
    top = sum(score)
    bottom = sum(score)

    for _ in range(n-1):
        score = list(map(int, input().split()))
        total = sum(score)
        if top < total:
            top = total
        elif bottom > total:
            bottom = total

    print(top, bottom)

Submission status: Accepted

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

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

while True:
    n = input()
    if n == 0:
        break
    Smax = 0
    Smin = 10 ** 9
    for i in range(n):
        S = sum(map(int, raw_input().split()))
        Smax = max(S, Smax)
        Smin = min(S, Smin)
    print Smax, Smin

Submission status: Runtime Error

Solution code:
def toBinary(block):
    return [sum(1 << i for i,bb in enumerate(b) if bb == "#") for b in block]

def toStr(bfield):
    return ["".join("." if f & (1<<i) == 0 else "#" for i in xrange(W)) for f in bfield]

def rotated(block):
    return map(lambda x:"".join(x),zip(*[b[:] for b in block]))[::-1]

def striped(block):
    ret = [b[:] for b in block]
    while ret[-1] == "." * len(ret[0]):
        ret.pop(-1)
    while ret[0] == "." * len(ret[0]):
        ret.pop(0)
    return ret

def canPut(x, y):
    if not(0 < x + w <= W or 0 < y + h <= H):
        return False
    for f,b in zip(bfield[y:y+h], bblock):
        if (f & (b << x)) != 0:
            return False
    return True

def puted(x, y):
    ret = bfield[:]
    for i,b in zip(xrange(y,y+h), bblock):
        ret[i] = ret[i] | (b << x)
    #print "\n".join(toStr(ret)),"\n"
    return ret

def count(bfield):
    return sum(1 for f in bfield if f == (1 << W) -1)

for _ in xrange(input()):
    h, w = map(int, raw_input().split())
    block = striped(rotated(striped([raw_input() for _ in xrange(h)])))
    h, w = len(block), len(block[0])
    H, W = map(int, raw_input().split())
    field = [raw_input() for _ in xrange(H)]
    bfield = toBinary(field)
    FLAG = False
    ans = 0
    for _ in xrange(4):
        block = rotated(block)
        h, w = w, h
        #print h,w,H,W
        #print "\n".join(field), "\n"
        #print "\n".join(block), "\n"        
        bblock = toBinary(block)
        for y in xrange(0, H - h + 1):
            for x in xrange(0, W - w + 1):
                if canPut(x, y):
                    FLAG = True
                    #print x,y
                    ans = max(ans, count(puted(x, y)))
    print ans if FLAG else -1