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;
}
相关推荐
ValhallaCoder4 小时前
hot100-栈
数据结构·python·算法·
WW_千谷山4_sch8 小时前
洛谷B3688:[语言月赛202212]旋转排列(新解法:deque双端队列)
数据结构·c++·算法
Zachery Pole8 小时前
【代码随想录】二叉树
算法
漂流瓶jz8 小时前
UVA-11214 守卫棋盘 题解答案代码 算法竞赛入门经典第二版
c++·算法·dfs·aoapc·算法竞赛入门经典·迭代加深搜索·八皇后
浮生09199 小时前
DHUOJ 基础 88 89 90
算法
fpcc9 小时前
并行编程实战——CUDA编程的Enhancing Memory Allocation
c++·cuda
v_for_van9 小时前
力扣刷题记录7(无算法背景,纯C语言)
c语言·算法·leetcode
先做个垃圾出来………9 小时前
3640. 三段式数组 II
数据结构·算法
白太岁10 小时前
通信:(3) 高并发网络通信:epoll + 边沿触发 + 非阻塞 IO + tcp
c语言·网络·c++·网络协议·tcp/ip
楼田莉子10 小时前
C++项目:日志&&线程池
linux·c++·学习·visual studio code