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;
}
相关推荐
CQ_YM6 小时前
数据结构之单向链表
c语言·数据结构·链表
暗然而日章7 小时前
C++基础:Stanford CS106L学习笔记 4 容器(关联式容器)
c++·笔记·学习
gihigo19987 小时前
matlab 基于瑞利衰落信道的误码率分析
算法
foxsen_xia7 小时前
go(基础06)——结构体取代类
开发语言·算法·golang
foxsen_xia7 小时前
go(基础08)——多态
算法·golang
leoufung7 小时前
用三色 DFS 拿下 Course Schedule(LeetCode 207)
算法·leetcode·深度优先
巨人张7 小时前
C++火柴人跑酷
开发语言·c++
im_AMBER8 小时前
算法笔记 18 二分查找
数据结构·笔记·学习·算法
C雨后彩虹9 小时前
机器人活动区域
java·数据结构·算法·华为·面试
MarkHD9 小时前
车辆TBOX科普 第53次 三位一体智能车辆监控:电子围栏算法、驾驶行为分析与故障诊断逻辑深度解析
算法