Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 7 点
問題文
高橋君はある同じ試験を T 回受験しました。各試験は 1 から N の番号のついた N 科目からなります。
高橋君は i 回目の試験では科目 j で P_{i,j} 点をとりました。
K=1,2,\ldots,T について次の問題に答えてください。
問題:
K 回目まで( K 回目含む)の試験の結果のうち、科目 j の最高得点を C_j とする。C_1+\ldots+C_N を求めよ。
制約
- 1 \leq T \leq 10^3
- 1 \leq N \leq 10
- 0 \leq P_{i,j} \leq 10^5
- 入力に含まれる値は全て整数である
入力
入力は以下の形式で標準入力から与えられる。
T N P_{1,1} P_{1,2} \ldots P_{1,N} \vdots P_{T,1} P_{T,2} \ldots P_{T,N}
出力
T 行出力せよ。i 行目には K=i のときの答えを出力せよ。
入力例 1
2 3 50 80 60 60 70 70
出力例 1
190 210
高橋君は 1 回目の試験では各科目で 50,80,60 点を、2 回目は 60,70,70 点を取りました。
- K=1 のときの答えは 50+80+60=190 です。
- K=2 のときの答えは 60+80+70=210 です。
入力例 2
4 4 1 2 3 4 2 3 4 1 4 1 2 3 3 4 1 2
出力例 2
10 13 15 16
Score : 7 points
Problem Statement
Takahashi took T tests of the same format. Each test has N subjects numbered 1 to N.
In the i-th test, he scored P_{i,j} points in Subject j.
For each K=1,2,\ldots,T, answer the following question.
Question:
Let C_j be the highest score in Subject j in the first K tests.
Find C_1+\ldots+C_N.
Constraints
- 1 \leq T \leq 10^3
- 1 \leq N \leq 10
- 0 \leq P_{i,j} \leq 10^5
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
T N P_{1,1} P_{1,2} \ldots P_{1,N} \vdots P_{T,1} P_{T,2} \ldots P_{T,N}
Output
Print T lines. The i-th line should contain the answer for K=i.
Sample Input 1
2 3 50 80 60 60 70 70
Sample Output 1
190 210
In the 1-st test, Takahashi scored 50,80,60 in Subject 1,2,3, respecitively. In the 2-nd test, he scored 60,70,70.
- The answer for K=1 is 50+80+60=190.
- The answer for K=2 is 60+80+70=210.
Sample Input 2
4 4 1 2 3 4 2 3 4 1 4 1 2 3 3 4 1 2
Sample Output 2
10 13 15 16