1.排序
2.前缀和
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
const int MAXN = 1e3 + 10;
struct que
{
int num;
int val;
}arr[MAXN];
bool cmp(que a, que b)
{
if(a.val != b.val)
return a.val < b.val;
return a.num < b.num;
}
int main()
{
int N;
cin>>N;
for(int i = 0; i < N; i++)
{
cin>>arr[i].val;
arr[i].num = i + 1;
}
sort(arr, arr + N, cmp);
double ans = 0;
int presum[MAXN] = {0};
for(int i = 1; i < N; i++)
{
presum[i] = presum[i - 1] + arr[i - 1].val;
ans += presum[i];
}
for(int i = 0; i < N; i++)
cout<<arr[i].num<<' ';
cout<<endl<<fixed<<setprecision(2)<<ans / N<<endl;
return 0;
}