为什么会错啊?爆0求助
  • 板块P1223 排队接水
  • 楼主bylgd
  • 当前回复3
  • 已保存回复3
  • 发布时间2023/12/2 14:32
  • 上次更新2023/12/2 16:00:48
查看原帖
为什么会错啊?爆0求助
920843
bylgd楼主2023/12/2 14:32

样例都过了啊

#include <bits/stdc++.h>
using namespace std;
#define int long long
struct node
{
	int id, t;
};
struct node t[100010];
bool cmp(node a, node b)
{
	return a.t < b.t;
}
signed main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++ )
	{
		cin >> t[i].t;
		t[i].id = i;
	}
	sort(t + 1, t + n + 1, cmp);
	int j = n - 1;
	double ans;
	for(int i = 1; i <= n; i ++ )
	{
		ans = ans + j * t[i].t;
		printf("%lld ", t[i].id);
		j --;
	}
	printf("\n");
	printf("%.2f ", ans / n);
	return 0;
}

2023/12/2 14:32
加载中...