稻花香里说丰年,再次听取WA声一片
查看原帖
稻花香里说丰年,再次听取WA声一片
1292414
LeonTexius楼主2024/9/24 18:55
#include<bits/stdc++.h>
using namespace std;
int n;
int t;
double tt;
struct water
{
	int x;
	int y;
	
}people[10000];
bool cmp(water s1, water s2) 
{
	return s1.y < s2.y;
}
int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n;i++)
	{
		scanf("%d",&people[i].x);
		people[i].y = i;
	}
	sort(people + 1,people + n + 1,cmp);
	for(int i = 1;i <= n;i++)
	{
		printf("%d ",people[i].y);
		t = t + people[i].x * (n - i + 1);
	}
	printf("\n");
	tt = t / n;
	printf("%.2f",tt);
	return 0;
	
}
2024/9/24 18:55
加载中...