AcWing 5395. 平均
原题链接
中等
作者:
馮
,
2024-03-24 23:53:08
,
所有人可见
,
阅读 2
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define x first
#define y second
using namespace std;
typedef pair<int, int> PII;
const int N = 100001;
int n;
PII ar[N];
long long ret = 0;
int get(int a, int b)
{
int res = 0;
for(int i = a; ; i ++)
{
res++;
if(ar[i].x != ar[i + 1].x )
break;
}
if(res > b)
{
for(int i = a; i < res - b + a; i ++)
{
ret += ar[i].y;
}
}
return res;
}
int main()
{
cin >> n;
for(int i = 0; i < n; i ++)cin >> ar[i].x >> ar[i].y;
int a = n / 10;
sort(ar, ar + n);
int i = 0;
while(i < n)
{
int b = get(i, a);
i += b;
}
cout << ret;
}