我的数据结构与算法题目集代码仓:https://github.com/617076674/Data-structure-and-algorithm-topic-set
原题链接:https://pintia.cn/problem-sets/15/problems/867
题目描述:
知识点:排序
思路:分别按4个规则排序4次
注意排名相同的情况,即如果某两个国家的金牌数都是10,那么其金牌排名应当相同!
时间复杂度是O(N*M)。空间复杂度是是O(N)。
C++代码:
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
struct country {
int number; //国家编号
int prizes[3]; //prizes[0]代表金牌数量,prizes[1]代表奖牌数量,prizes[2]代表国民人口数量
int rank;