CCF201909_1

题解:

cpp 复制代码
#include<bits/stdc++.h>
using namespace std;

struct tree {
	int id;
	int apple;
	int cut = 0;
};

bool cmp(tree a, tree b)
{
	if (a.cut == b.cut)
	{
		return a.id < b.id;
	}
	return a.cut > b.cut;
}

int main()
{
	int n, m;
	cin >> n >> m;
	tree t[n];
	int cutNum = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> t[i].apple;
		t[i].id = i + 1;
		for (int j = 0; j < m; j++)
		{
			cin >> cutNum;
			t[i].cut += (-cutNum);
		}
		t[i].apple -= t[i].cut;
	}
	int sum = 0;
	sort(t, t + n, cmp);
	for (int i = 0; i < n; i++)
	{
		sum += t[i].apple;
	}
	cout << sum << " " << t[0].id << " " << t[0].cut << endl;
	return 0;
}
相关推荐
房开民7 小时前
c++总结
java·开发语言·c++
好大哥呀7 小时前
C++ 多态
java·jvm·c++
阿豪学编程8 小时前
LeetCode724.:寻找数组的中心下标
算法·leetcode
墨韵流芳8 小时前
CCF-CSP第41次认证第三题——进程通信
c++·人工智能·算法·机器学习·csp·ccf
hz_zhangrl8 小时前
CCF-GESP 等级考试 2026年3月认证C++五级真题解析
c++·青少年编程·程序设计·gesp·c++五级·gesp2026年3月·gesp c++五级
Σίσυφος19008 小时前
C++ 多肽经典面试题
开发语言·c++·面试
csdn_aspnet9 小时前
C# 求n边凸多边形的对角线数量(Find number of diagonals in n sided convex polygon)
开发语言·算法·c#
凌波粒9 小时前
LeetCode--349.两个数组的交集(哈希表)
java·算法·leetcode·散列表
crescent_悦10 小时前
C++:The Largest Generation
java·开发语言·c++
paeamecium11 小时前
【PAT甲级真题】- Student List for Course (25)
数据结构·c++·算法·list·pat考试