第二题~ class Node{ public int waitTIme; public int excTime; public int in ; } public class Main2 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); List<Node> wait =new LinkedList<>(); LinkedList<Node> exec =new LinkedList<>(); int size = scanner.nextInt(); for (int i = 0; i < size; i++) { Node node = new Node(); node.waitTIme = scanner.nextInt(); node.excTime = scanner.nextInt(); wait.add(node); } wait.sort(Comparator.comparingInt(a -> a.waitTIme)); int time = 0; while (wait.size() != 0 || exec.size() != 0) { time++; for (int i = 0; i < wait.size(); i++) { Node node = wait.get(i); if (time >= node.waitTIme) { wait.remove(node); node.in = time; exec.add(node); } } Node work = exec.peekFirst(); if (work != null) { if (time - work.in >= work.excTime) { exec.pop(); } } } System.out.println(time); } }