Skip to content

Instantly share code, notes, and snippets.

@KT-Yeh
Created December 29, 2013 04:06
Show Gist options
  • Save KT-Yeh/8167284 to your computer and use it in GitHub Desktop.
Save KT-Yeh/8167284 to your computer and use it in GitHub Desktop.
#include<algorithm>
#include<cstdio>
using namespace std;
struct Node{
double tf;
int order;
};
bool cmp(Node a,Node b){
return a.tf>b.tf;
}
int main(){
int Case,N;
scanf("%d",&Case);
while(Case--){
scanf("%d",&N);
int time[1011],fine[1011],i;
Node a[1011];
for(i=0;i<N;i++){
scanf("%d %d",&time[i],&fine[i]);
a[i].tf=fine[i]*1.0/time[i]; //轉double記得*1.0
a[i].order=i+1;
}
sort(a,a+N,cmp);
printf("%d",a[0].order);
for(i=1;i<N;i++)
printf(" %d",a[i].order);
printf("\n");
if(Case) //注意最後一個Case不能有換行
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment