题目描述
多变少 也是多变成avg
贪心
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
ArrayList<Integer>[] w = new ArrayList[10];
for (int i = 0; i < 10; i++) {
w[i] = new ArrayList<>();
}
for (int i = 0; i < n; i++) {
int a = scanner.nextInt();
int b = scanner.nextInt();
w[a].add(b);
}
long res = 0;
int avg = n / 10;
for (int i = 0; i < 10; i++) {
if (w[i].size() > avg) {
w[i].sort((x, y) -> x - y);
for (int j = 0; j < w[i].size() - avg; j++) {
res += w[i].get(j);
}
}
}
System.out.println(res);
}
}