_Vistion_ @ 2024-09-13 10:25:31
#include <bits/stdc++.h>
#define ll long long
using namespace std;
struct soulve{
string s;
ll y,d,m;
};
bool cmp(soulve a, soulve b){
return a.y+a.d+a.m > b.y+b.d+b.m;
}
int main(){
soulve vis[10001];
ll n;
cin>>n;
for(int i=0; i<n; i++){
cin>>vis[i].s>>vis[i].y>>vis[i].d>>vis[i].m;
}
sort(vis, vis+n, cmp);
cout<<vis[0].s<<" "<<vis[0].y<<" "<<vis[0].d<<" "<<vis[0].m;
return 0;
}
by 2019yyy @ 2024-09-13 10:43:26
如果有多个总分相同的学生,输出靠前的那位,你的代码没有
by _Vistion_ @ 2024-09-13 11:21:14
@2019yyy dalao能帮忙改一下吗qwq
by xutengyuan2012 @ 2024-09-13 12:00:30
@YZ_zhang 把sort改成stable_sort即可通过
求关
by dongzirui0817 @ 2024-09-13 12:18:05
@YZ_zhang 因为 stable_sort
是稳定排序,sort
不稳定
by _Vistion_ @ 2024-09-13 14:21:04
@xutengyuan2012 && @dongzirui0817 谢谢两位dalao 已关
by SuperBeetle @ 2024-09-13 19:33:16
@YZ_zhang 你是怎么做到做了黑题不会橙题的???!!!
by _Vistion_ @ 2024-09-13 23:06:52
@SuperBeetle 没学stable_sort
by _Vistion_ @ 2024-09-13 23:07:32
@SuperBeetle 那道题纯玄学