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;
}
相关推荐
咚咚王者9 小时前
人工智能之RAG工程 第一章 RAG 基础与前置知识
人工智能·算法
handler019 小时前
【算法模板】最小生成树:稠密图选 Prim,稀疏图选 Kruskal
c语言·数据结构·c++·算法
许长安9 小时前
RPC 异步调用基本使用方法:基于官方helloworld-async 示例
c++·经验分享·笔记·rpc
Chase_______10 小时前
LeetCode 2461 & 1423:定长滑窗变体精讲,从 HashMap 判重到正难则反的转化技巧
算法·leetcode·职场和发展
sparEE10 小时前
c++面向对象:对象的赋值
开发语言·c++
此生决int10 小时前
快速复习之数据结构篇——栈和队列
数据结构·c++
WL_Aurora10 小时前
【每日一题】二分算法
python·算法
昵称小白10 小时前
子串专题部分
数据结构·算法·哈希算法
H_BB10 小时前
第17届蓝桥杯备战历程
c++·算法·职场和发展·蓝桥杯
anew___11 小时前
算法分析与设计课程全算法核心概述|期末复习+知识梳理
算法