View Code of Problem 5

#include  <stdio.h>
int main(){
  int t;
  scanf("%d",&t);
  while(t--){
    int m,n,a1,b,a[1000],i,j;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
    scanf("%d %d",&a1,&b);
      a[i]=a1*100000+b;
    }
    for(i=0;i<m;i++){
      int max=0,temp;
      for(j=0;j<n;j++){
        if(a[max]<a[j]){
         max=j;
        }
      }
     if(i==0) printf("%d",max+1);
      else printf(" %d",max+1);
      a[max]=-1;
   
    }
  printf("\n");
  }


}

Double click to view unformatted code.


Back to problem 5