Advertisement
Rapela

uva 10026

Mar 19th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. // https://uva.onlinejudge.org/external/100/p10026.pdf
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5.  
  6. bool func(pair<int,int> a, pair<int,int> b)
  7. {
  8.   return a.first < b.first;
  9. }
  10.  
  11.  
  12. int main()
  13. {
  14.  
  15. int n;scanf("%d",&n);
  16.  
  17. while(n--)
  18. {
  19.  
  20. int s;scanf("%d",&s);
  21. vector<pair<double,int> > v;
  22.  
  23. for(int i = 0; i < s;i++)
  24. {
  25. double a,b;
  26. scanf("%lf %lf",&a,&b);
  27. pair<double,int> aux;
  28. aux.first = b*a;
  29. aux.second = i+1;
  30. v.push_back(aux);
  31. }
  32.  
  33. //stable_sort(v.begin(),v.end(),func);
  34. stable_sort(v.begin(),v.end(),func);
  35.  
  36. for(int i = 0; i < v.size();i++)
  37. {
  38.    if(i == v.size()-1)
  39.     cout << v[i].second << endl;
  40.    else
  41.     cout << v[i].second << " ";
  42. }
  43. }
  44.  
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement