82分求调
查看原帖
82分求调
1073652
sunwhite楼主2024/8/28 16:23
#include <bits/stdc++.h>
using namespace std;

struct x{
	int time;
	int id;
};

x a[1010];

bool cmp(x a, x b){
	return a.time < b.time;
}

int main(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i].time;
		a[i].id = i;
	}
	a[0].time = -1;
	a[0].id = -1;
	
	sort(a, a+n+1, cmp);
	
	for(int i = 1; i <= n; i++){
		cout << a[i].id << " ";
	}
	
	//求总等待时长 
	int sum = 0;
	for(int i = 1; i < n; i++){
		for(int j = 1; j <= i; j++){
			sum += a[j].time;
		}
	}
	printf("\n%.2f\n", sum * 1.0 / n);
	return 0;
}
2024/8/28 16:23
加载中...