import java.io.BufferedReader; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.PriorityQueue; public class Main { public BufferedReader br; /** * メイン処理 * @throws IOException */ public void Proc() throws IOException { int[] inpt = getIntArray(); int q = inpt[0]; int k = inpt[1]; PriorityQueue q1 = new PriorityQueue<>(); PriorityQueue q2 = new PriorityQueue<>(); StringBuilder ans = new StringBuilder(); for(int i=0; itm[1]) { q1.add(tm[1]*-1); q2.add(q1.poll()*-1); } else { q2.add(tm[1]); } } else { if(q2.size()<=0){ ans.append("-1\n"); } else { ans.append(q2.poll()+"\n"); } } } System.out.print(ans.toString()); } private long[] getLongArray() throws IOException { String[] inpt = br.readLine().split(" "); List lst = new ArrayList<>(); for(String tmp:inpt) { lst.add(Long.parseLong(tmp)); } long[] ret = new long[lst.size()]; for(int i=0; i lst = new ArrayList<>(); for(String tmp:inpt) { lst.add(Integer.parseInt(tmp)); } int[] ret = new int[lst.size()]; for(int i=0; i