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