题解
2023-08-14 10:40:01
发布于:广东
1阅读
0回复
0点赞
#include <cstdio>
#include <iostream>
#include <algorithm>
int main()
{
int n;
double sum = 0.0f;
std::cin >> n;
std::pair<int, int> * a = new std::pair<int, int>[n];
for (int i = 0; i < n; ++i)
{
std::cin >> a[i].first;
a[i].second = i + 1;
}
std::sort(a, a + n);
for (int i = 0; i < n; ++i)
{
sum += a[i].first * (n - i - 1);
}
printf("%.2f", sum / n);
delete[] a;
return 0;
}
这里空空如也
有帮助,赞一个