F.cpp 603 B

12345678910111213141516171819202122232425262728
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int n;
  6. cin>>n;
  7. vector<double>a,b;
  8. for(int i=0;i<n;i++){
  9. string s;
  10. double x;
  11. cin>>s>>x;
  12. if(s=="male"){
  13. a.push_back(x);
  14. }else{
  15. b.push_back(x);
  16. }
  17. }
  18. sort(a.begin(),a.end());
  19. sort(b.begin(),b.end(),greater<double>());
  20. for(int i=0;i<a.size();i++)cout<<fixed<<setprecision(2)<<a.at(i)<<" ";
  21. for(int i=0;i<b.size();i++){
  22. if(i)cout<<" ";
  23. cout<<fixed<<setprecision(2)<<b.at(i);
  24. }
  25. cout<<endl;
  26. }