201909-1 小明种苹果
/*
* CSP
* 201909-1 小明种苹果*/
#include <stdio.h>
#include <vector>
#include <math.h>
using namespace std;
vector<vector<int> > tree;
int N, M;//N:苹果树棵树 M:操作轮数
int allApple;//所有苹果树
int subMaxTree;//去掉果子最多的苹果树
int subApple = 0;//去掉果子最多的苹果树 去掉的果子
void myprint() {
for (int i = 0; i < tree.size(); i++) {
int tempSubApple = 0;
for (int j = 0; j < tree[i].size(); j++) {
allApple += tree[i][j];
if (j > 0) {
tempSubApple += abs(tree[i][j]);
}
}
if (subApple < tempSubApple) {
subApple = tempSubApple;
subMaxTree = i + 1;
}
}
printf("%d %d %d", allApple, subMaxTree, subApple);
}
int main() {
scanf("%d%d", &N, &M);
for (int i = 0; i < N; i++) {
vector<int> temp;
for (int j = 0; j <= M; j++) {
int tempNum;
scanf("%d", &tempNum);
temp.push_back(tempNum);
}
tree.push_back(temp);
}
myprint();
return 0;
}
/*
3 3
73 -8 -6 -4
76 -5 -10 -8
80 -6 -15 0
*/