WA 54
查看原帖
WA 54
1058749
King_and_Grey楼主2024/6/5 13:51
#include <bits/stdc++.h>
using namespace std;
#define int long long
struct node {
	int time,id;
} a[1005];

int n;
float times;

bool cmp(node a,node b) {
	return a.time < b.time;
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	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 << " ";
	}
	for(int j = n - 1;j >= 1;j--) { 
		int i = n - j;
		times += a[i].time * j; 
	}
	cout << "\n" << fixed << setprecision(2) << times / n << endl;
	return 0;
}

rt

给关注!!!

2024/6/5 13:51
加载中...