4 条题解
-
0
#include<iostream> #include<iomanip> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<string> #include<algorithm> #define LL long long using namespace std; const int N=1e5+10; const int Inf=0x3f3f3f3f; int n; double time1 = 1.00 * 0; struct per { int t; int num; }a[N]; bool cmp(per a, per b){ if(a.t==b.t){ return a.num<b.num; } return a.t < b.t; } int main(){ int n; cin >> n; for(int i = 1; i <= n; i++) { cin >> a[i].t; a[i].num = i; } sort(a + 1, a + n + 1, cmp); int sum = n - 1; for(int i = 1; i <= n; i++) { time1 += 1.00 * a[i].t * sum; sum--; cout << a[i].num << ' ' ; } time1 /= 1.00 * n; cout << endl; printf("%.2lf", time1); }
信息
- ID
- 3007
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 8
- 标签
- 递交数
- 343
- 已通过
- 56
- 上传者