Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- class Codechef
- {
- static FastIO f;
- static TreeSet<Integer> h;
- public static void main(String args[]) throws IOException
- {
- f = new FastIO();
- int t = f.ni(), n;
- while(t-->0)
- {
- n = f.ni();
- h = new TreeSet<>();
- while(n-->0)
- {
- if(f.ni() == 1)
- h.add(f.ni());
- else
- f.out(ceil(f.ni()) + "\n");
- }
- }
- f.flush();
- }
- public static int ceil(int n)
- {
- Integer a = h.ceiling(n);
- if(a == null)
- return -1;
- return a;
- }
- public static class FastIO
- {
- BufferedReader br;
- BufferedWriter bw, be;
- StringTokenizer st;
- public FastIO()
- {
- br = new BufferedReader(new InputStreamReader(System.in));
- bw = new BufferedWriter(new OutputStreamWriter(System.out));
- be = new BufferedWriter(new OutputStreamWriter(System.err));
- st = new StringTokenizer("");
- }
- private void read() throws IOException
- {
- st = new StringTokenizer(br.readLine());
- }
- public String ns() throws IOException
- {
- while(!st.hasMoreTokens())
- read();
- return st.nextToken();
- }
- public int ni() throws IOException
- {
- return Integer.parseInt(ns());
- }
- public long nl() throws IOException
- {
- return Long.parseLong(ns());
- }
- public float nf() throws IOException
- {
- return Float.parseFloat(ns());
- }
- public double nd() throws IOException
- {
- return Double.parseDouble(ns());
- }
- public char nc() throws IOException
- {
- return ns().charAt(0);
- }
- public int[] nia(int n) throws IOException
- {
- int[] a = new int[n];
- for(int i = 0; i < n; i++)
- a[i] = ni();
- return a;
- }
- public long[] nla(int n) throws IOException
- {
- long[] a = new long[n];
- for(int i = 0; i < n; i++)
- a[i] = nl();
- return a;
- }
- public char[] nca() throws IOException
- {
- return ns().toCharArray();
- }
- public void out(String s) throws IOException
- {
- bw.write(s);
- }
- public void flush() throws IOException
- {
- bw.flush();
- be.flush();
- }
- public void err(String s) throws IOException
- {
- be.write(s);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement