fisher626 @ 2024-07-12 16:37:18
只用源代码
by Tiffake @ 2024-07-12 16:38:42
https://www.luogu.com.cn/problem/solution/P1093
by tankewei911 @ 2024-07-12 16:40:17
@fisher626
#include<bits/stdc++.h>
using namespace std;
const int MAXX = 3e2 + 5;
struct pp{
int a, b, c, m;
int t;
}n[MAXX];
int s;
bool cmp(pp a, pp b){
if(a.t != b.t){
return a.t > b.t;
}else{
if(a.a != b.a){
return a.a > b.a;
}else{
return a.m < b.m;
}
}
}
int main(){
cin >> s;
for(int i = 1; i <= s; i++){
cin >> n[i].a >> n[i].b >> n[i].c;
n[i].m = i;
n[i].t = n[i].a + n[i].c + n[i].b;
}
sort(n + 1, n + s + 1, cmp);
for(int i = 1; i <= min(s, 5); i++){
cout << n[i].m << " " << n[i].t << endl;
}
return 0;
}
by xuruizhe0711 @ 2024-07-15 17:35:23
int n;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i].china>>a[i].math>>a[i].english;
a[i].score=a[i].china+a[i].math+a[i].english;
a[i].name=i;
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=5;i++){
cout<<a[i].name<<" "<<a[i].score<<endl;
}
return 0;
}
by skyqiu @ 2024-07-29 09:32:12
#include<bits/stdc++.h>
using namespace std;
int const MAX=310;
int n;
struct student{
int id,chinese,total;
}stu[MAX];
bool cmp(student a,student b){
if(a.total!=b.total)return a.total>b.total;
if(a.chinese!=b.chinese)return a.chinese>b.chinese;
return a.id<b.id;
}
int main(){
cin>>n;
for(int i=0;i<n;i++){
int math,english;
cin>>stu[i].chinese>>math>>english;
stu[i].total=stu[i].chinese+math+english;
stu[i].id=i+1;
}
sort(stu,stu+n,cmp);
for(int i=0;i<5;i++)
cout<<stu[i].id<<" "<<stu[i].total<<endl;
return 0;
}