import java.util.*; public class Main{ public static void main(String[] args){ Scanner scanner = new Scanner(System.in); while(scanner.hasNext()){ //据题意可知此处需要用到TreeMap,利用自动排序的特性 TreeMap<Integer,Integer> treeMap = new TreeMap<>(); ...