Atcoder Code Festival 2017 Team Relay J - Indifferent

Posted memory-of-winter

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Atcoder Code Festival 2017 Team Relay J - Indifferent相关的知识,希望对你有一定的参考价值。

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

题解:从小到大排序,$sumlimits_{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的主要内容,如果未能解决你的问题,请参考以下文章

atcoder CODE FESTIVAL 2017 qual C D - Yet Another Palindrome Partitioning

@atcoder - CODE FESTIVAL 2017 Final - J@ Tree MST

Atcoder Code Festival 2017 qual C 10.22 D题题解

[Atcoder Code Festival 2017 Qual B Problem F]Largest Smallest Cyclic Shift

[AtCoder Code Festival 2017 QualB C/At3574] 3 Steps - 二分图染色,结论

CODE FESTIVAL 2017 qual B 解题报告