#include "stdlib.h" #include "iostream" #include "string.h" #include "math.h" int main() { int t; scanf("%d",&t); while (t--) { int n, m, a[999], b[999]; scanf("%d%d",&n,&m); for (int i = 0; i<n; i++ ) { scanf("%d %d",&a[i],&b[i]); } for (int i = 0; i<m; i++) { int t = 0; for (int j = 0; j<n; j++ ) if (a[j]>a[t]) t = j; else if (a[j] == a[t] && b[j] > b[t]) { t = j; } printf("%d",t+1); a[t] = -1; if (i<m - 1) printf(" "); } } return 0; system("pause"); } |
Double click to view unformatted code.