QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#210028#5740. Testing Subjects Usually DieExplodingKonjacWA 1ms3708kbC++201.1kb2023-10-10 22:10:592023-10-10 22:11:01

Judging History

你现在查看的是最新测评结果

  • [2023-10-10 22:11:01]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3708kb
  • [2023-10-10 22:10:59]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using LL=long long;
using LD=long double;
using UI=unsigned int;
using ULL=unsigned long long;

#ifndef DADALZY
#define FILEIO(file) freopen(file".in","r",stdin),freopen(file".out","w",stdout)
#define LOG(...) void()
#else
#define FILEIO(file)
#define LOG(...) fprintf(stderr,__VA_ARGS__)
#endif

int n;
double c,p[100005],q[100005],sp[100005];

int main()
{
	cin>>n>>c,c/=100;
	double sum=0;
	for(int i=1;i<=n;i++) cin>>p[i],sum+=p[i];
	for(int i=1;i<=n;i++) p[i]/=sum;
	sort(p+1,p+n+1);
	for(int i=1;i<=n;i++) sp[i]=sqrt(p[i]);
	double ans=0;
	if(c==1) ans=1/p[n];
	else
	{
		auto calcq=[&](double C)
		{
			double sum=0;
			for(int i=1;i<=n;i++)
				q[i]=(C*sp[i]-c)/(1-c),sum+=q[i];
			return sum;
		};
		double l=0,r=1e9;
		for(int _=0;_<100;_++)
		{
			double mid=(l+r)/2;
			if(calcq(mid)<=1) l=mid;
			else r=mid;
		}
		calcq(l);
		double sf=0,sg=0;
		for(int i=1;i<=n;i++)
		{
			sf+=p[i]/(c+(1-c)*q[i]);
			sg+=p[i]*q[i]/(c+(1-c)*q[i]);
		}
		ans=sf/sg;
	}
	cout<<setprecision(8)<<fixed<<ans<<'\n';
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3696kb

input:

4 100
25 25 25 25

output:

4.00000000

result:

ok found '4.0000000', expected '4.0000000', error '0.0000000'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3696kb

input:

2 0
1 4

output:

1.80000000

result:

ok found '1.8000000', expected '1.8000000', error '0.0000000'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

5 0
245 802 95 452 756

output:

4.46853100

result:

ok found '4.4685310', expected '4.4685310', error '0.0000000'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3648kb

input:

5 10
85 144 62 67 925

output:

3.08233733

result:

ok found '3.0823373', expected '3.0823373', error '0.0000000'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3708kb

input:

5 20
573 598 705 893 279

output:

4.66556407

result:

ok found '4.6655641', expected '4.6655641', error '0.0000000'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

5 25
533 195 166 109 527

output:

3.93380793

result:

ok found '3.9338079', expected '3.9338079', error '0.0000000'

Test #7:

score: -100
Wrong Answer
time: 0ms
memory: 3640kb

input:

5 50
498 942 71 637 663

output:

2.98972856

result:

wrong answer 1st numbers differ - expected: '3.8718857', found: '2.9897286', error = '0.2278366'