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;
}
相关推荐
平生不晚6 小时前
在 SVG 体系里画一条任意的线
前端·算法
Hhy_11077 小时前
《C++深度解构02》类和对象(上)——定义规范、内存对齐与 this 指针全解
c语言·开发语言·c++·学习·visual studio
晚风叙码7 小时前
C++哈希表实现:开放定址法和链地址法 (哈希桶)
数据结构·c++·哈希算法·散列表
imaol17 小时前
哈希表--数据结构
数据结构·散列表
逆境不可逃7 小时前
LeetCode 双题:415. 字符串相加与 143. 重排链表
算法
2601_950760797 小时前
TNF-α:自身免疫疾病治疗的核心靶点与信号通路解析
人工智能·算法·蛋白
呜喵王阿尔萨斯8 小时前
C/C++ 杂记-1
c++
不会代码的小猴8 小时前
2. 了解Qt
开发语言·c++·笔记·qt·算法
比奇堡裤头村8 小时前
统计学习方法——支持向量机
算法·支持向量机·学习方法
吃着火锅x唱着歌8 小时前
LeetCode 3597.分割字符串
算法·leetcode·职场和发展