7:13 On the same day Noah, with Shem, Ham, and Japheth, his sons, and his wife and his sons' wives, went into the ark;
7:14 And with them, every sort of beast and cattle, and every sort of thing which goes on the earth, and every sort of bird.
7:15 They went with Noah into the ark, two and two of all flesh in which is the breath of life.
7:16 Male and female of all flesh went in, as God had said, and the ark was shut by the Lord.
Once abroad,many have suggested that Noah's problems really began, with only 8 people to feed and water, to provide fresh air and sanitation
for the huge menagerie of animals.Given a list of how much time it takes for one person to feed an animal, you must find the minimum account of
total time needed to feed all of the animals.The time given from any person to feed any animal will not exceed 10000.
输入格式
【The input contains several test cases.】 (see more in hint). For each test case,the first line contains the number of animals, n (1 <= n <= 10000).
The following 8 lines contain the 8 * n time matrix, where each element shows the time for one person to feed an animal.
Elements in each line is separated by a single space.
输出格式
For each test case,output a single line containing an integer that is the sum of the minimum time needed to feed all of the animals.
样例输入
3 10 20 30 20 15 20 2 10 8 4 8 30 3 8 10 50 70 10 20 30 40 10 30 20 2 10 20 20 15 2 10 4 8 3 8 50 70 20 30 10 30
样例输出
18 10
#include <stdio.h>
#define MAX 10000
int main() {
int i,j,rop;
int time[8][MAX],tmp[MAX],data[100];
int n,min;
rop=0;
while(scanf("%d",&n) == 1) {
min = 0;
for(i=0; i<8; i++)
for(j=0; j<n; j++)
scanf("%d",&time[i][j]);
for(j=0; j<n; j++)
tmp[j] = time[0][j];
for(j=0; j<n; j++) {
for(i=0; i<8; i++) {
tmp[j] = (tmp[j] < time[i][j])? tmp[j]:time[i][j];
}
min = min + tmp[j] ;
}
data[rop]=min;
rop++;
}
for(i=0; i<rop; i++)
printf("%d\n",data[i]);
return 0;
}