本题利用了动态二维数组来计算 一共是10行数据每行都是每一个数字所对应的代价现在想要补齐那么要先求取平均数然后判断当前行的数据是否是大于这个长度 如果大于要将当前行的数据进行排序去掉多余的并且代价最少的
#include <bits/stdc++.h>
using namespace std;
const int N =100010;
int n;
vector<int> num[10];
int main() {
int ans = 0;
long long res = 0;
cin>>n;
ans = n/10;
for(int i = 1;i <= n;i++) {
int a,b;
scanf("%d%d",&a,&b);
num[a].push_back(b);
}
for(int i = 0;i < 10;i++) {
if(num[i].size() > ans){
sort(num[i].begin(),num[i].end());
for(int j = 0;j < num[i].size() - ans;j++) {
res += num[i][j];
}
}
}
cout<<res<<endl;
return 0;
}