输入格式:
输入首先给出两个正整数 N(≤1000)和 M(≤100),分别为月饼的种类数(于是默认月饼种类从 1 到 N 编号)和参与统计的城市数量。
接下来 M 行,每行给出 N 个非负整数(均不超过 1 百万),其中第 i 个整数为第 i 种月饼的销量(块)。数字间以空格分隔。
输出格式:
在第一行中输出最大销量,第二行输出销量最大的月饼的种类编号。如果冠军不唯一,则按编号递增顺序输出并列冠军。数字间以 1 个空格分隔,行首尾不得有多余空格。
输入样例:
5 3
1001 992 0 233 6
8 0 2018 0 2008
36 18 0 1024 4
输出样例:
2018
3 5
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
int i,j;
int n,m;
int k[1000],t=0;
int max1=0,max2=0;
int sum[1000]={0};
int a[100][1000];
scanf("%d %d",&n,&m);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
}
for(j=0;j<n;j++)
{
for(i=0;i<m;i++)
sum[j]+=a[i][j];
if(max2<sum[j])
max2=sum[j];
}
printf("%d\n",max2);
for(i=0;i<n;i++)
if(sum[i]==max2)
k[t++]=i+1;
for(i=0;i<t-1;i++)
printf("%d ",k[i]);
printf("%d\n",k[t-1]);
return 0;
}