1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include<cstdio>
#include<cmath>

enum
{
	MAX = 100010
};

int tab[6][MAX];

double abs(double x) {return(x<0)?-x:x;}

int main()
{
	int n, k; scanf("%d%d", &n, &k);
	for(int i = 0; i < k; i++)
	{
		for(int j = 0; j < n; j++)
			scanf("%d",tab[i]+j);
	}
	int rr = 0;
	for(int i = 0; i < n; i++)
	{
		long long sum = 0;
		for(int j = 0; j < k; j++)
			sum += tab[j][i];
		long long avg = sum/k;
		double r_avg = sum/double(k);
		if(abs(r_avg-avg) > 0.001)
		{
			if(tab[rr][i] > avg)
				avg=ceil(r_avg);
			else if(tab[rr][i] < avg)
				avg=floor(r_avg);
			rr = (rr+1)%k;
		}
		printf("%lld ", avg);
	}
	printf("\n");
	return 0;
}