求调,0pts,样例未过,maybe降序出了问题,玄关
查看原帖
求调,0pts,样例未过,maybe降序出了问题,玄关
737219
YONEX楼主2023/9/16 21:46
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct px
{
	ll shu;
	ll xuhao;
};
px a[100];
bool cmp(px x,px y)
{
	return x.shu >y.shu ;
}
bool cmp1(px x,px y)
{
	return x.xuhao >y.xuhao ;//
}
int main()
{
    int ans=0;
    int b[9];
    for(int i=1;i<=8;i++)
    {
    	cin>>a[i].shu;a[i].xuhao=i;
    }
    sort(a+1,a+9,cmp);
//    for(int i=a[1].xuhao;i<=a[9].xuhao;i++)
//    for(int j=0;j<i;j++)
//    if(a[i].xuhao<a[i+1].xuhao)
//    sort(a[j]+1,a[j+1]+1)
   for(int i=1;i<=5;i++)
   {
   	ans+=a[i].shu; 
   }
   sort(a+1,a+6,cmp1);
   
     cout<<ans<<endl;
     
    for(int i=1;i<=5;i++)
   {
   	cout<<a[i].xuhao<<" "; 
   }

	return 0;
}
2023/9/16 21:46
加载中...