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 小时前
aiDgeScanner架构与实现
c++·ide·物联网·架构·node.js·aiot
王老师青少年编程6 小时前
csp信奥赛C++高频考点专项训练之字符串 --【字符串排序】:生日
c++·字符串·csp·高频考点·信奥赛·生日·字符串排序
AI科技星6 小时前
微积分:变化与累积的数学(分层大白话解释版)
人工智能·算法·数学建模·数据挖掘·机器人
sinat_286945196 小时前
llm wiki
人工智能·算法·chatgpt
kyle~6 小时前
ROS2---消息过滤
开发语言·c++·机器人·ros2
xieliyu.6 小时前
Java手搓二叉树:基础遍历与核心操作全解析
java·开发语言·数据结构·学习
期待のcode6 小时前
Redis数据类型
运维·数据结构·redis
雪度娃娃6 小时前
C++异步日志系统
开发语言·c++
博界IT精灵6 小时前
图的遍历(哈喜老师)
数据结构·考研·算法·深度优先
sheeta19986 小时前
LeetCode 每日一题笔记 日期:2026.05.10 题目:2770. 达到末尾下标所需的最大跳跃次数
笔记·算法·leetcode