题目大意:输入n代表有n个人在队伍中,输入n个数字代表每个人需要等待的时间,输出等待时间的最小平均值
思路就是:排序,然后简单的计算
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
int t[1005];
int main(){
int n;
cin>>n;
for(int i = 0; i < n; i++){
cin>>t[i];
}
sort(t,t + n);
int sum = 0,temp = 0;
for(int i = 0; i < n; i++){
sum += (n - temp) * t[i];
temp++;
}
double ave;
ave = sum / n;
cout<<setiosflags(ios::fixed)<<setprecision(2)<<ave<<endl;
return 0;
}