fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. Scanner in = new Scanner(System.in);
  14. int n = in.nextInt();
  15. int[][] data = new int[n][];
  16. int[] result = new int[n];
  17. for (int i = 0; i < n; i++)
  18. {
  19. int m = in.nextInt();
  20. data[i] = new int[m];
  21. int o = 0;
  22. for (int j = 0; j < m; j++)
  23. {
  24. int l = in.nextInt();
  25. Boolean b = false;
  26. for (int k : data[i])
  27. if (k == l) b = true;
  28. if (!b) data[i][o++] = l;
  29. }
  30. Arrays.sort(data[i]);
  31. result[i] = data[i][data[i].length - in.nextInt()];
  32. }
  33. for (int item : result)
  34. System.out.println(item);
  35. }
  36. }
Success #stdin #stdout 0.13s 321344KB
stdin
2
5
100 90 90 100 70
2
10
1 2 3 3 3 400 3 4 3 1
4
stdout
90
2