卡了一下 输出“-”
n = 0 1 2 都得自动补“-”
注意一下就行 简单题
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
const int maxn = 1010;
struct node
{
string id;
int num;
int dif;
double ave;
}Node[maxn];
bool cmp(node a, node b)
{
if(a.dif != b.dif) return a.dif > b.dif;
else return a.ave < b.ave;
}
int main()
{
int n,k,x;
cin >> n;
string str;
for(int i = 0; i < n; i++)
{
set<int> s;
cin >> str >> k;
Node[i].id = str;
Node[i].num = k;
while(k--)
{
cin >> x;
s.insert(x);
}
Node[i].dif = s.size();
Node[i].ave = 1.0*Node[i].num / Node[i].dif;
}
sort(Node, Node + n,cmp);
int flag = 0;
if(n == 0) cout <<"- - -";
for(int i = 0; i < 3; i++)
{
if(flag) cout << " ";
if(n==0) cout << "-";
else
{
cout << Node[i].id;
flag = 1;
}
if(n > 0) n--;
}
return 0;
}