首页 > 其他 > 详细

Atcoder Code Festival 2017 Team Relay J - Indifferent

时间:2018-07-05 19:31:24      阅读:160      评论:0      收藏:0      [点我收藏+]

题目大意:共$2n$个价格$p_i$。两人轮流取。你每次取最大的,对方每次随机取。问你取的期望和是多少。

题解:从小到大排序,$\sum\limits_{i=0}^{2n-1} \frac{i*p_i}{2n-1}$

卡点:

 

C++ Code:

#include<cstdio>
#include<algorithm>
using namespace std;
long long n,s[200005];
long long ans;
int main(){
	scanf("%lld",&n);
	for (int i=0;i<n*2;i++)scanf("%lld",&s[i]);
	sort(s,s+n*2);
	for (long long i=0;i<n*2;i++)ans+=i*s[i];
	printf("%.10lf",ans/(double)(2*n-1));
	return 0;
}

  

 

Atcoder Code Festival 2017 Team Relay J - Indifferent

原文:https://www.cnblogs.com/Memory-of-winter/p/9269853.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!