解法:按照单位双鞋的罚款数排序输出
代码:
/*
uva10026 Shoemaker's Problem
AC By Warteac
2013-4-12
Runtime:0.008s
*/
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct node{
double fine;
int no;
node(double x,int y){
fine = x; no = y;
}
};
bool cmp(node n1,node n2){
return n1.fine > n2.fine;
}
int main(){
int n, m ,t=0;
double a,b;
vector <node> shoe;
cin >> n;
while(n--){
cin >> m; t=0; shoe.clear();
while(m--){
cin >> a >> b;
shoe.push_back(node(b/a,++t));
}
sort(shoe.begin(),shoe.end(),cmp);
for(int x =0 ; x < shoe.size(); x++){
cout << shoe[x].no ;
if(x<shoe.size()-1) cout << " ";
else cout << endl;
}
if(n) cout << endl;
}
return 0;
}