kuaihuoya @ 2021-11-14 19:36:38
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i,j,b1,b2,b3,a[301],b[301],maxn,maxm;
memset(a,-1,sizeof(a));
cin>>n;
for(i=1;i<=n;i++)
{
scanf("%d%d%d",&b1,&b2,&b3);
int m=b1+b2+b3;
int k=(m*100000)+(b1*1000)+(100-i); //把几个值合并
b[i]=m;
a[i]=k;
}
for(i=1;i<=5;i++) //找出前五个大的
{
maxn=0;
for(j=1;j<=n;j++) //打擂台
{
if(a[j]>maxn)
{
maxn=a[j];
maxm=j;
}
}
cout<<maxm<<' '<<b[maxm]<<endl;
a[maxm]=-1; //标记,以免重复
}
return 0;
}
一百的,借鉴借鉴,
by int64 @ 2021-11-14 19:37:53
%
by MatrixGroup @ 2021-11-14 19:39:22
哦
by 追梦之鲸 @ 2021-11-14 19:44:20
%
by InterN_NOT_FOUND @ 2021-11-14 19:46:41
%%%
by Veranda @ 2021-11-14 19:46:47
彳亍
by InterN_NOT_FOUND @ 2021-11-14 19:51:17
@kuaihuoya 更加简单的程序:
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline bool isnum(char ch){return ch>='0'&&ch<='9';}
inline int read()
{
int x=0,f=1;char ch=getchar();
while (!isnum(ch)){if (ch=='-') f=-1;ch=getchar();}
while (isnum(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;
}
struct Fu_kingBi_chXxs{
int Chinese,total,id;
}g[11451419];
bool cmp(Fu_kingBi_chXxs a,Fu_kingBi_chXxs b){
return a.total==b.total?(a.Chinese==b.Chinese?(a.id<b.id):a.Chinese>b.Chinese):a.total>b.total;
}
int n=read();
signed main()
{
for(int i=1;i<=n;i++){
g[i].id=i;g[i].Chinese=read();
g[i].total=g[i].Chinese+read()+read();
}
sort(g+1,g+n+1,cmp);
for(int i=1;i<=5;i++){
printf("%lld %lld\n",g[i].id,g[i].total);
}
return 0;
}
by AlbrecRoon @ 2021-11-14 19:51:35
好
by 起名字重要吗 @ 2021-11-14 20:10:26
不要在讨论区发题解
by qsceszthn @ 2021-11-14 20:33:33
orz