zzh0118 @ 2024-11-10 15:46:20
代码如下
#include<bits/stdc++.h>
using namespace std;
struct people{
int yw;
int sx;
int yy;
int id;
int all;
}a[200010];
bool cmp(people x,people y){
if(x.all!=y.all)return x.all>y.all;
else if(x.yy!=y.yy)return x.yy>y.yy;
return x.id>y.id;
}
long long n;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i].yw>>a[i].sx>>a[i].yy;
a[i].id=i;
a[i].all=a[i].yw+a[i].sx+a[i].yy;
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=5;i++){
cout<<a[i].id<<" "<<a[i].all<<endl;
}
return 0;
}
本人认为应该是哪个奇怪的点,样例都能过
by zzh0118 @ 2024-11-10 15:49:06
@cccyyymmm 求助
by zzh0118 @ 2024-11-10 15:57:39
现在80了:
#include<bits/stdc++.h>
using namespace std;
struct people{
int yw;
int sx;
int yy;
int id;
int all;
}a[200010];
bool cmp(people x,people y){
if(x.all!=y.all)return x.all>y.all;
else if(x.yy!=y.yy)return x.yy>y.yy;
return x.id<y.id;
}
long long n;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i].yw>>a[i].sx>>a[i].yy;
a[i].id=i;
a[i].all=a[i].yw+a[i].sx+a[i].yy;
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=5;i++){
cout<<a[i].id<<" "<<a[i].all<<endl;
}
return 0;
}
by zzh0118 @ 2024-11-10 16:01:23
@zzh0118 现在100了赶紧给关
#include<bits/stdc++.h>
using namespace std;
struct people{
int yw;
int sx;
int yy;
int id;
int all;
}a[200010];
bool cmp(people x,people y){
if(x.all!=y.all)return x.all>y.all;
else if(x.yw!=y.yw)return x.yw>y.yw;
return x.id<y.id;
}
long long n;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i].yw>>a[i].sx>>a[i].yy;
a[i].id=i;
a[i].all=a[i].yw+a[i].sx+a[i].yy;
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=5;i++){
cout<<a[i].id<<" "<<a[i].all<<endl;
}
return 0;
}
by xuziheng0905 @ 2024-11-10 16:33:37
楼主竟然把语文( yw
)写成英语( yy
),可见楼主不爱上语文课
by zzh0118 @ 2024-11-11 12:56:44
@xuziheng0905 。。。