QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#356098#8242. V-Diagramucup-team2681#WA 49ms3852kbC++201.1kb2024-03-17 15:31:452024-03-17 15:31:45

Judging History

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

  • [2024-03-17 15:31:45]
  • 评测
  • 测评结果:WA
  • 用时:49ms
  • 内存:3852kb
  • [2024-03-17 15:31:45]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int maxn=3e5+5;
inline int read() {
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*f;
}
typedef long long ll;
typedef long double lb;
int T,n,a[maxn];
int main() {
	T=read();
	while(T--) {
		n=read();
		int p=0,Min=2e9;
		for(int i=1;i<=n;++i) {
			a[i]=read();
			if(a[i]<Min) {
				Min=a[i];
				p=i;
			}
		}
		ll res=a[p]+a[p-1]+a[p+1];
		ll sum1=0,sum2=0;
		int now1=p-2,now2=n-p-1;
		for(int i=1;i<=now1;++i) sum1+=a[i];
		for(int i=p+2;i<=n;++i) sum2+=a[i];
		lb ans=(lb)(sum1+sum2+res)/(lb)n;
		ll tmp=0;
		for(int i=p-2;i;--i) {
			tmp+=a[i];
			ans=max(ans,(lb)(tmp+res)/(lb)(p+3-i));
			ans=max(ans,(lb)(tmp+res+sum2)/(lb)(n-i+1));
		}
		tmp=0;
		for(int i=p+2;i<=n;++i) {
			tmp+=a[i];
			ans=max(ans,(lb)(tmp+res)/(lb)(i-p+2));
			ans=max(ans,(lb)(tmp+res+sum1)/(lb)i);
		}
		ans=max(ans,(lb)res/3.0);
		printf("%.15Lf\n",ans);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3852kb

input:

2
4
8 2 7 10
6
9 6 5 3 4 8

output:

6.750000000000000
5.833333333333333

result:

ok 2 numbers

Test #2:

score: -100
Wrong Answer
time: 49ms
memory: 3784kb

input:

100000
3
948511478 739365502 813471668
3
881046825 27458122 398507422
3
987554257 399092415 924260278
3
984128569 125199021 716360525
3
529589236 45783262 313507287
3
645443456 85994112 226010681
3
914820717 228360911 572267310
3
418958362 56703604 195276041
3
64461646 26764720 26995581
3
914535039 ...

output:

-597872882.666666666686069
435670789.666666666686069
-661353448.666666666686069
608562705.000000000000000
296293261.666666666686069
319149416.333333333343035
571816312.666666666686069
223646002.333333333343035
39407315.666666666667879
383253737.666666666686069
-697292126.666666666686069
-651679941.0...

result:

wrong answer 1st numbers differ - expected: '833782882.6666666', found: '-597872882.6666666', error = '1.7170606'