不知道哪里错了。
# include <bits/stdc++.h>
# define int long long
using namespace std;
map<string, int>mp;
const int MAXN = 1e3 + 10;
struct code {
string s;
int n;
};
code a[MAXN];
bool cmp(code x, code y) {
return x.n > y.n;
}
map<string, bool>flag;
signed main()
{
// freopen("1.in","r",stdin);
// freopen("1.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
string name; int score;
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> name >> score;
if (flag[name] == 0) mp[name] = score;
else mp[name] = max(mp[name], score);
flag[name] = 1;
}
n = 0;
for (auto x : mp) {
a[++n].s = x.first;
a[n].n = x.second;
}
cout << n<<endl;
sort(a + 1, a + 1 + n, cmp);
for (int i = 1; i <= n; i++) {
int x = i;
while (a[x - 1].n == a[x].n&&x>1) x--;
x--;
cout << a[i].s << " ";
if (x == 0) {
cout << "pro";
}
else if (x > 0.5 * n) {
cout << "noob";
}
else if (x > 0.2 * n && x <= 0.5 * n) {
cout << "random";
}
else if (x > 0.1 * n && x <= 0.2 * n) {
cout << "average";
}
else if (x > 0.01 * n && x <= 0.1 * n) {
cout << "handcore";
}
cout << endl;
}
return 0;
}
违规紫衫