⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1941.cpp

📁 哈尔滨工业大学ACM 竞赛网上在线试题集锦的源代码
💻 CPP
字号:
/*  This Code is Submitted by wywcgs for Problem 1941 on 2006-01-29 at 13:08:59 */ 
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
	int N, time[1024];
	int i, total;

	while(scanf("%d", &N) == 1) {
		for(i = 0; i < N; i++) scanf("%d", &time[i]);
		sort(time, time+N);
		int n = (N - 1) / 2;
		if(N % 2 == 0) {
			total = 0;
			for(i = 0; i < n; i++) total += (time[2*i] + time[2*i+1]) * (n-i);
		} else {
			total = time[0] * n;
			for(i = 1; i < n; i++) total += (time[2*i-1] + time[2*i]) * (n-i);
		}
		printf("%.3lf\n", (double)total / N);
	}

	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -