Java program for the above approach
import java . util . Vector ; public class GFG { static int MAX = ( int ) 1e5 ; public static class pair { long first ; long second ; pair ( long first , long second ) { this . first = first ; this . second = second ; } }