PAT L2-009. 抢红包
原题链接
简单
作者:
青丝蛊
,
2021-04-10 12:34:50
,
所有人可见
,
阅读 246
#include <bits/stdc++.h>
using namespace std;
struct node
{
int sum = 0, cnt = 0, h;
} q[10010];
int main()
{
int n;
cin >> n;
for (int i = 1; i <= n; i++)
{
int k;
cin >> k;
int sum = 0;
while (k--)
{
int a, b;
cin >> a >> b;
q[a].cnt++;
q[a].sum += b;
sum += b;
}
q[i].h = i;
q[i].sum -= sum;
}
sort(q + 1, q + n + 1, [](auto &x, auto &y) {
return tie(x.sum, x.cnt, y.h) > tie(y.sum, y.cnt, x.h);
});
for (int i = 1; i <= n; i++) printf("%d %.2lf\n", q[i].h, q[i].sum / 100.0);
return 0;
}