CCF-CSP 认证 201909-1 小明种苹果

CCF-CSP 认证 201909-1 小明种苹果

#include 
using namespace std;

int n, m;
struct tree{
    int num;
    int id;
}a[1005];
long long tot;
bool cmp(tree a, tree b){
    return a.num == b.num ? a.id < b.id : a.num > b.num;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m;
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        tot += x;
        a[i].id = i;
        for (int j = 0; j < m; j++){
            cin >> x;
            tot += x;
            a[i].num -= x;
        }
    }
    sort(a, a + n, cmp);
    cout << tot << " " << a[0].id + 1 << " " << a[0].num<< "\n";
    return 0;
}

你可能感兴趣的:(CCF-CSP认证)