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