提交时间:2025-05-01 21:24:33
运行 ID: 319793
#include <bits/stdc++.h> using namespace std; struct Pe{ string e; double h; }p[45]; bool cmp(Pe x,Pe y){ if(x.e!=y.e) return x.e>y.e; if(x.e=="male") return x.h<y.h; return x.h>y.h; } int main (){ int n; cin>>n; for(int i=1;i<=n;i++){ cin>>p[i].e>>p[i].h; } sort(p+1,p+n+1,cmp); for(int i=1;i<=n;i++){ cout<<fixed<<setprecision(2)<<p[i].h<<" "; } return 0; }