shzuaeno @ 2020-10-07 09:29:05
#include <iostream>
#include <algorithm>
using namespace std;
struct cj{
int yw;
int sx;
int yy;
int zf;
int xh;
}a[305];
bool cmp(cj w,cj u)
{
return w.zf>u.zf;
}
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i].yw>>a[i].sx>>a[i].yy;
a[i].xh=i;
a[i].zf=a[i].yw+a[i].sx+a[i].yy;
}
sort(a+1,a+n+1,cmp);
int p=0,ans=0,k=0;
for(int i=2;i<=n;i++)
{
if(a[i].zf==a[i-1].zf&&a[i].zf>a[i+1].zf)
{
ans+=2;
k++;
continue;
}
if(a[i].zf==a[i-1].zf&&a[i].zf==a[i+1].zf)
{
if(i==2)
ans+=2;
else
ans++;
k++;
continue;
}
if(a[i].zf<a[i-1].zf&&k+p<5)
p++;
if(a[i].zf<a[i-1].zf&&k+p>=5)
break;
}
ans+=p-1;
for(int i=1;i<=ans;i++)
for(int i=2;i<=ans;i++)
{
if(a[i].zf==a[i-1].zf)
if(a[i].yw>a[i-1].yw)
swap(a[i],a[i-1]);
}
for(int i=1;i<=5;i++)
cout<<a[i].xh<<" "<<a[i].zf<<" "<<endl;
return 0;
}
by flame_soul @ 2020-10-07 09:31:38
先按总分从高到低排序,如果两个同学总分相同,再按语文成绩从高到低排序,如果两个同学总分和语文成绩都相同,那么规定学号小的同学 排在前面,这样,每个学生的排序是唯一确定的。
by shzuaeno @ 2020-10-07 09:33:57
额
by shzuaeno @ 2020-10-07 09:34:14
这个我明白
by shzuaeno @ 2020-10-07 09:34:33
我究竟是哪里出了问题
by flame_soul @ 2020-10-07 09:37:19
bool cmp(cj w,cj y)
{
if(w.zf==y.zf)
{
if(w.yw==y.yw)
{
if(w.sx==y.sx)
{
if(w.yy==y.yy)
return w.xh<w.xh;
else
return w.yy>y.yy;
}
else
return w.sx>y.sx;
}
else
return w.yw>y.yw
}
return w.zf>u.zf;
}
未测
by shzuaeno @ 2020-10-07 09:45:49
大佬,不行啊,还是90,还是第八个测试点
by dujs722 @ 2020-10-07 10:05:41
只能说明你不行
by shzuaeno @ 2020-10-08 14:30:30
对,你不行