Konnyaku_q @ 2023-09-22 23:44:36
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
int n;
struct feng
{
int y,s,i;
int num;
int bian;
}ah[1000000];
long long cmp(feng a,feng b)
{
if(a.num==b.num&&a.y!=b.y)
{
return a.y>b.y;
}
else if(a.num==b.num&&a.y==b.y)
{
return a.bian<b.bian;
}
else
{
return a.num>b.num;
}
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
ah[i].bian=i;
cin>>ah[i].y>>ah[i].s>>ah[i].i;
ah[i].num=ah[i].y+=ah[i].s+=ah[i].i;
}
sort(ah+1,ah+1+n,cmp);
for(int i=1;i<=5;i++)
{
cout<<ah[i].bian<<" "<<ah[i].num<<endl;
}
}
by YangXiaopei @ 2023-09-23 09:21:28
@Konnyaku_q
把第一个for
里的ah[i].num=ah[i].y+=ah[i].s+=ah[i].i;
改成ah[i].num=ah[i].y+ah[i].s+ah[i].i;
就行了