使用了TreeMap,实现了键值对对应以及排序 import java.util.Scanner; import java.util.TreeMap; import java.util.Map; public class Main{ public static void main(String... args){ Scanner scan = new Scanner(System.in); int n = scan.nextInt(); Map<Integer,Integer> map = new TreeMap<>...