-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathL2-021_点赞狂魔.cpp
44 lines (40 loc) · 981 Bytes
/
L2-021_点赞狂魔.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>
#include <unordered_set>
#include <vector>
#include <algorithm>
using namespace std;
#define min(a, b) (a < b ? a : b)
int main() {
ios::sync_with_stdio(false);
int n, k, tag;
string name;
vector<tuple<int, float, string>> ans;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> name >> k;
unordered_set<int> tags;
for (int j = 0; j < k; j++) {
cin >> tag;
tags.insert(tag);
}
int cnt = tags.size();
float avg = k / (float)tags.size();
ans.push_back({cnt, avg, name});
}
sort(ans.begin(), ans.end(), [&](tuple<int, float, string> a, tuple<int, float, string> b) {
if (get<0>(a) == get<0>(b))
return get<1>(a) < get<1>(b);
else return get<0>(a) > get<0>(b);
});
if (ans.size() == 0) cout << "- - -" << endl;
else {
cout << get<2>(ans[0]);
int len = min(3, ans.size());
for (int i = 1; i < len; i++)
cout << " " << get<2>(ans[i]);
for (int i = 0; i < 3 - len; i++)
cout << " -";
cout << endl;
}
return 0;
}