#传智杯---志愿者

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+" ");
        }
    }
}
  • 8
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值