0
已解决
吴子尧
中级守护
中级守护
题目链接: 酷町堂:1251
- #include<iostream> #include<cstdio> #include<algorithm> using namespace std; struct cm{ int a,id; }a[500005]; bool cmp(cm x,cm y){ if(x.a!=y.a){ return x.a<y.a; } return x.id<y.id; } int main(){ int n,sum=0; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i].a; a[i].id=i; } sort(a+1,a+n+1,cmp); for(int i=1;i<=n;i++){ cout<<a[i].id<<" "; sum+=a[i].a*(n-i); } cout<<endl; printf("%.2f",(double)sum/(n-2)); return 0; }