import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); for(int i = 0;i < t;i++) { int n = scanner.nextInt(); int m = scanner.nextInt(); int[][] a =new int[n][2]; for(int j = 0 ;j < n;j++) { a[j][0] = scanner.nextInt(); a[j][1] = scanner.nextInt(); } for(int j = 0;j < m;j++) { int max = a[0][0]; int pos = 0; for(int k = 1;k < n;k++) { if(max < a[k][0]) { max = a [k][0]; pos = k; } if(max == a[k][0]) { if(a[k][1] > a[pos][1]) { max = a[k][0]; pos = k; } } } a[pos][0] = -1; if(j == m-1) { System.out.println(pos+1); }else { System.out.print(pos+1+" "); } } } } } |
Double click to view unformatted code.