萌新的题解
2025-03-16 20:01:20
发布于:上海
5阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int n;
double ans = 0;
struct water{
int time , id;
}a[1009];
bool cmp(water x , water y){
return x.time < y.time;
}
int main(){
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i].time;
a[i].id = i;
}
sort(a + 1 , a + n + 1 , cmp);
for(int i = 1; i <= n; i++){
cout << a[i].id << ' ';
ans += a[i].time * (n - i);
}
printf("\n%.2f" , ans / n);
return 0;
}
这里空空如也
有帮助,赞一个