提交时间:2023-10-14 14:05:27

运行 ID: 28375

#include<iostream> #include<string> using namespace std; struct s{ int num; double id; double yw; double sx; double yy; int sc; }a[333]; int n; int main() { cin>>n; for(int i=1;i<=n;i++){ cin>>a[i].yw>>a[i].sx>>a[i].sx>>a[i].yy; a[i].id=i; a[i].sc=a[i].yw=a[i].sx+a[i].yy; } for(int i=1;i<=n;i++){ for(int j=1;j<n-i;j++){ if(a[j].sc<a[j+1].sc){ swap(a[j],a[j+1]); } else if(a[j].sc==a[j+1].sc&&a[j].yw<a[j+1].yw){ swap(a[j],a[j+1]); } else if(a[j].sc==a[j+1].sc&&a[j].yw&&a[j].id<a[j+1].id){ swap(a[j],a[j+1]); } } } for(int i=1;i<=5;i++){ cout<<a[i].id<<" "<<a[i].sc<<endl; } return 0; }