提交时间:2019-10-28 21:46:03

运行 ID: 1895

#include<bits/stdc++.h> #define MAXN 1000 using namespace std; int n,total; struct num{ int t,b; }a[MAXN]; bool cmp(num x,num y){ return x.t<y.t; } int main(){ freopen("water.in","r",stdin); freopen("water.out","w",stdout); 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; return 0; }