题目传递门
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1010;
struct water {
int num, time;
} p[N];
bool cmp(const water &a, const water &b) {
if (a.time != b.time) return a.time < b.time;//首先按接水时间排序,谁小,谁在前
return a.num < b.num;//如果接水时间一样长,那么谁号小谁靠前
}
int n;
LL sum;
int main() {
//输入
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &p[i].time);
p[i].num = i;
}
//排序
sort(p + 1, p + n + 1, cmp);
for (int i = 1; i <= n; i++) {
printf("%d ", p[i].num); //第几号
sum += (n - i) * p[i].time; //这个n-i用的妙
}
printf("\n%.2lf", 1.0 * sum / n);
return 0;
}