PAT L2-027. 名人堂与代金券
原题链接
简单
作者:
青丝蛊
,
2021-04-13 18:22:01
,
所有人可见
,
阅读 343
#include <bits/stdc++.h>
using namespace std;
typedef pair<string, int> PII;
vector<PII> v;
int main()
{
int n, g, k;
cin >> n >> g >> k;
int sum = 0;
while (n--)
{
string s;
int x;
cin >> s >> x;
if (x >= 60)
{
if (x >= g) sum += 50;
else sum += 20;
}
v.push_back({s, x});
}
sort(v.begin(), v.end(), [](auto &x, auto &y) {
return tie(x.second, y.first) > tie(y.second, x.first);
});
cout << sum << endl;
int h = 1, i = 0;
while (h <= k)
{
if (!i) cout << h << ' ' << v[i].first << ' ' << v[i].second << endl;
else
{
if (v[i].second != v[i - 1].second)
{
h = i + 1;
if (h > k) break;
}
cout << h << ' ' << v[i].first << ' ' << v[i].second << endl;
}
i++;
}
return 0;
}