33 lines
653 B
C++
33 lines
653 B
C++
#include <iostream>
|
|
#include <utility>
|
|
#include <iomanip>
|
|
#include <set>
|
|
using namespace std;
|
|
|
|
struct cmp{
|
|
bool operator()(const pair<int, int>& a, const pair<int, int>& b) const{
|
|
if(a.second != b.second) return a.second < b.second;
|
|
else return a.first < b.first;
|
|
}
|
|
};
|
|
int main(){
|
|
set<pair<int, int>, cmp> s;
|
|
int n;
|
|
cin >> n;
|
|
int tmp;
|
|
double all = 0;
|
|
for(int i = 0; i < n; i++){
|
|
cin >> tmp;
|
|
s.emplace(make_pair(i + 1, tmp));
|
|
}
|
|
auto x = s.begin();
|
|
for(int i = 0; i < n; i++){
|
|
cout << (*x).first << " ";
|
|
all += (n - i - 1) * (*x).second;
|
|
x++;
|
|
}
|
|
cout << endl;
|
|
cout << fixed << setprecision(2) << all / n << endl;
|
|
return 0;
|
|
}
|