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;
}
相关推荐
地平线开发者20 小时前
PTQ 量化数值范围与优化
算法·自动驾驶
sali-tec20 小时前
C# 基于halcon的视觉工作流-章68 深度学习-对象检测
开发语言·算法·计算机视觉·重构·c#
测试人社区-小明21 小时前
智能弹性伸缩算法在测试环境中的实践与验证
人工智能·测试工具·算法·机器学习·金融·机器人·量子计算
罗西的思考21 小时前
【Agent】MemOS 源码笔记---(5)---记忆分类
人工智能·深度学习·算法
程序员zgh1 天前
Linux系统常用命令集合
linux·运维·服务器·c语言·开发语言·c++
獭.獭.1 天前
C++ -- STL【unordered_set与unordered_map的实现】
开发语言·c++·unordered_map·unordered_set
qq_433554541 天前
C++数位DP
c++·算法·图论
AshinGau1 天前
Softmax 与 交叉熵损失
神经网络·算法
似水এ᭄往昔1 天前
【C++】--AVL树的认识和实现
开发语言·数据结构·c++·算法·stl
程序员zgh1 天前
常用通信协议介绍(CAN、RS232、RS485、IIC、SPI、TCP/IP)
c语言·网络·c++