提交时间:2019-11-02 18:58:25
运行 ID: 1934
#include<bits/stdc++.h> #define MAXN 1000 using namespace std; int n,total; struct num{ int t,b; }a[MAXN+1]; bool cmp(num x,num y){ return x.t<y.t; } int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>a[i].t; a[i].b=i; } sort(a+1,a+n+1,cmp); for(int i=1;i<n;i++){ cout<<a[i].b<<" "; total+=a[i].t*(n-i); } cout<<a[n].b<<endl; cout<<fixed<<setprecision(2)<<total*1.0/n<<endl; }