@@ -0,0 +1,1368 @@
+import java.io.*;%0Aimport java.util.*;%0Aimport java.text.*;%0Aimport java.math.*;%0Aimport java.util.regex.*;%0A%0A/**%0A * This is essentially a sorting problem, we create Order class to maintain time + delay and also%0A * order id. Extending Comparable allows to provide custom order in case of matching time + delay.%0A */%0Apublic class Solution %7B%0A  static class Order implements Comparable%3COrder%3E %7B%0A    int id;%0A    int time;%0A    int delay;%0A%0A    Order(int id, int time, int delay) %7B%0A      this.id = id;%0A      this.time = time;%0A      this.delay = delay;%0A    %7D%0A%0A    public int eta() %7B%0A      return this.time + this.delay;%0A    %7D%0A%0A    @Override%0A    public int compareTo(Order other) %7B%0A      if (this.eta() %3C other.eta()) return -1;%0A      if (this.eta() %3E other.eta()) return 1;%0A      if (this.id %3C this.id) return -1;%0A      if (this.id %3E this.id) return 1;%0A      return 0;%0A    %7D%0A  %7D%0A%0A  private static void sort(Order%5B%5D orders) %7B%0A    Arrays.sort(orders);%0A  %7D%0A%0A  public static void main(String%5B%5D args) %7B%0A    Scanner in = new Scanner(System.in);%0A    int n = in.nextInt();%0A    Order%5B%5D orders = new Order%5Bn%5D;%0A    for (int i = 0; i %3C n; i++) %7B%0A      int time = in.nextInt();%0A      int delay = in.nextInt();%0A      orders%5Bi%5D = new Order(i + 1, time, delay);%0A    %7D%0A%0A    sort(orders);%0A    for (Order order : orders) %7B%0A      System.out.print(order.id + %22 %22);%0A    %7D%0A    System.out.println();%0A  %7D%0A%7D%0A

add solution