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