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