100WAC代码(爱看不看)
查看原帖
100WAC代码(爱看不看)
1299866
renmafan楼主2024/8/13 21:38
#include <bits/stdc++.h>
using namespace std;
int n;
struct node
{
	int t;
	int id;
} a[1005];
bool cmp(node x,node y)
{
	return x.t < y.t;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 1;i <= n;i++)
	{
		cin >> a[i].t;
		a[i].id = i;
	}   
	sort(a +1,a+n+1,cmp);   
	for (int i = 1;i <= n;i++) cout << a[i].id << " ";
	cout << "\n";
	double ans = 0;
	for (int i = 2;i <= n;i++){
		for (int j = 1;j < i;j++)
		{
			ans += a[j].t;
		}
	} 
	printf("%.2lf\n",ans/n);      
	return 0;
}
2024/8/13 21:38
加载中...