#include<iostream> #include <stdio.h> #include <string.h> using namespace std; int main() { int t; scanf("%d", &t); for (int i = 0; i < t; i++) { int n, m; int a[10000], b[100]; int max = 0; int flag = 0; scanf("%d %d", &n, &m); for (int j = 0; j < n; j++) { scanf("%d %d", &a[j], &b[j]); } while (m > 0) { for (int j = 0; j < n; j++) { if (a[j] > a[max]) { max = j; } else if (a[j] == a[max]) { if (b[j] > b[max]) { max = j; } } } if (flag == 0) printf("%d", max+1); else printf(" %d", max+1); m--, flag++; a[max] = 0; b[max] = 0; } printf("\n"); } return 0; } |
Double click to view unformatted code.