U E D R , A S I H C RSS

Shoemaker's_Problem/곽병학

#include<iostream>
#include<algorithm>
#include<map>
using namespace std;

typedef struct ps {
public:
	int first;
	int second;
}ps;

class opt {
public:
	bool operator() (const ps &s1, const ps &s2) {
		int a = s1.first * s2.second;
		int b = s1.second * s2.first;
		return a < b;
	}
};
int main() {
	int cs, line, t, s, key, val;
	ps p;
	multimap<ps, int, opt> mm;
	multimap<ps, int, opt>::iterator it;

	cin>>cs;

	while(cs--) {
		cin>>line;
		for(int i=0; i<line; i++) {
			cin>>t>>s;
			p.first = t;
			p.second = s;
			mm.insert(make_pair(p, i+1));
		}
		for(it = mm.begin(); it != mm.end(); ++it)
			cout<<it->second<<" ";
		
		cout<<endl<<endl;
		mm.clear();
	}
	return 0;
}

// 빈칸 출력...
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:01
Processing time 0.0135 sec