public class Main{ public static void main(String[] args){         Scanner sc = new Scanner(System.in);   int n = sc.nextInt();  int[][] myd = new int[n][2];   for(int i = 0; i < n; i++){             myd[i][0] = sc.nextInt();  myd[i][1] = sc.nextInt();  }         TreeMap px = new TreeMap<Integer,Integer>(new Comparator<Integer>(){ @Override  public int compare(Integer o1, Integer o2){ return o1.compareTo(o2);  }         });   for(int i = 0; i < n; i++){             px.put(i,myd[i][0]-myd[i][1]);  } int min = 0;  Set<Integer> keySet = px.keySet();  Iterator it = keySet.iterator();  int count = 0;  while(it.hasNext()){ int key = Integer.parseInt(it.next().toString());  min += myd[key][0]*count + myd[key][1]*(n-(count+1));  count++;  }         System.out.println(min);   } } 满意度那个 我是这样做的
点赞 1

相关推荐

03-10 11:23
门头沟学院 Java
点赞 评论 收藏
分享
还是想躺平了:那就认清呗,按他们说的读研读博,爆着家里米然后边玩边学,考不上就再考一年反正花的家里钱,等他们被啃得受不了了来怪你,就说当年都要找到工作了被谁搞没了
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务