题目要求
P1583题目链接
感觉需要排两次序,一次是为了获取额外权重而进行的排序,另一次是加上额外权重以后为了得到最终权重而进行的排序。
为了便于随机访问,我还是选择了数组这个线性结构。
另外,在处理过程中为了方便起见,我使用了Person这个类,将id和value封装在一起。
排序的时候使用了lambda表达式……
AC代码(Java语言描述)import java.util.Arrays;
import java.util.Scanner;
public class Main {
private static class Person {
Integer value;
Integer id;
Person(int value, int id) {
this.value = value;
this.id = id;
}
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int num = scanner.nextInt(), k = scanner.nextInt();
Person[] person_array = new Person[num];
int[] external_array = new int[10];
for (int i = 0; i
关注
打赏
热门博文
- 【Linux】Ubuntu20.04安装和卸载MySQL8
- 【Linux】Ubuntu 20.04 报错 curl: (23) Failure writing output to destination 的解决方法
- 【Java】JUnit 4.13.2 警告 ‘assertEquals(double, double)‘ is deprecated 的解决方法
- 【JavaScript】处理 @parcel/transformer-js: Browser scripts cannot have imports or exports.
- 【Python】处理TypeError: Plain typing.NoReturn is not valid as type argument
- 【Python】Matplotlib可视化50例
- 【C语言】C语言修改MySQL数据库
- 【Java】从默认包导入类和对象报错的解决方法
- 【Java】panel.getGraphics()报错空指针异常的解决方法
- 【Java】IDEA编译Java项目报错 java: 找不到符号 的解决方法