import java.util.*;   class Peo implements Comparable<Peo> {     int a;     int b;       public Peo(int a, int b) {         this.a = a;         this.b = b;     }       public int compareTo(Peo o) {         if (this.a == o.a)             return this.b - o.b;         else             return o.a - this.a;     }   }   public class Main {     public static void main(String[] args) {         Scanner sc = new Scanner(System.in);         int n = sc.nextInt();         List<Peo> list = new ArrayList();         for(int i=0;i<n;i++) {             Peo peo = new Peo(sc.nextInt(),sc.nextInt());             list.add(peo);         }         Collections.sort(list);         long res = 0;         for(int i=0;i<list.size();i++) {             res += list.get(i).a*(i)+list.get(i).a*(list.size()-i-1);         }         System.out.println(res);     } }
点赞 7

相关推荐

12-03 03:32
安徽大学 Java
点赞 评论 收藏
分享
苗条的伊泽瑞尔最喜欢...:同28届被压力了,电科✌就不能去卷算法吗?把Java留给我们双非卷
投递快手等公司10个岗位
点赞 评论 收藏
分享
12-27 22:46
门头沟学院 Java
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务