#include<stdio.h> void main() { int t; int m, n; int a, b; int i, j; int apple[1000]; int pear[1000]; scanf("%d", &t); while (t--) { scanf("%d %d", &n, &m); for (i = 0; i < n; i++) { scanf("%d %d", &a, &b); apple[i] = a; pear[i] = b; } for(i = 0; i < m; i++) { int 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; } } } |
Double click to view unformatted code.