import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Scanner; public class P8832志愿者_ { static class volunteer{ //志愿者---静态内部类 public int id; //记录编号 public int t; //记录时长 public int k; //记录工作难度系数 public int conty; //贡献度 public volunteer(int id,int t, int k) { this.id = id; this.t = t; this.k = k; conty = t*k; } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); //多少名志愿者 List<volunteer> list = new ArrayList<>(); for (int i = 1; i <= n; i++) { //i是志愿者编号 list.add(new volunteer(i,sc.nextInt(),sc.nextInt())); } Collections.sort(list, new Comparator<volunteer>() { //定制排序--->对符合条件的编号进行重新分配 public int compare(volunteer o1, volunteer o2) { if (o1.conty != o2.conty) { return o2.conty - o1.conty; }else if(o1.t != o2.t) { return o2.t - o1.t; }else { return o1.id - o2.id; } } }); for (int i = 0; i < list.size(); i++) { System.out.print(list.get(i).id+" "); } } }
#传智杯---志愿者
最新推荐文章于 2024-10-05 12:07:50 发布