CCF 201909-1 小明种苹果
#include <iostream> #include <bits/stdc++.h> #include <string> using namespace std; typedef struct { int base; vector<int> subtract; int end; }Tree; vector<Tree> tree; int main() { int n,m; cin>>n>>m; while(n--) { Tree temp; cin>>temp.base; for(int i=0;i<m;i++) { int tempp; cin>>tempp; temp.subtract.push_back(tempp); } tree.push_back(temp); } int t=0; for(int i=0;i<tree.size();i++) { tree[i].end=tree[i].base; for(int j=0;j<tree[i].subtract.size();j++) tree[i].end+=tree[i].subtract[j]; t+=tree[i].end; } int maxi=0,maxsubtract=0; for(int i=0;i<tree.size();i++) { if(tree[i].end-tree[i].base<maxsubtract) { maxsubtract=tree[i].end-tree[i].base; maxi=i; } } cout<<t<<" "<<maxi+1<<" "<<abs(maxsubtract)<<endl; }