QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#729589#8242. V-Diagramnice_botWA 72ms3900kbC++17872b2024-11-09 17:25:412024-11-09 17:25:47

Judging History

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

  • [2024-11-09 17:25:47]
  • 评测
  • 测评结果:WA
  • 用时:72ms
  • 内存:3900kb
  • [2024-11-09 17:25:41]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cassert>
#include<algorithm>
using namespace std;

const int mN=300005;
int n,a[mN]; 
//long long pre[mN];
int main()
{
	//freopen("","r",stdin);//freopen("","w",stdout);
	int tsk;
	scanf("%d",&tsk);
	while(tsk--){
		scanf("%d",&n);
//		pre[0]=0;
		for(int i=1;i<=n;++i){
			scanf("%d",a+i);
//			pre[i]=pre[i-1]+a[i];
		}
		int v=0;
		for(int i=1;i<=n;++i)
			if(i>1&&i<n&&a[i]<a[i-1]&&a[i]<a[i+1])
				v=i;
		assert(v!=0);
		double l=0,m=0,r=0;
		m=a[v-1]+a[v]+a[v+1];
		for(int i=1;i<v-1;++i) l+=a[i];
		for(int i=v+2;i<=n;++i) r+=a[i];
		printf("%.12lf\n",max(max((l+m)/(v+1),(m+r)/(n-v+2)),(l+m+r)/n));
//		printf("%.12lf\n",max(max((double)1.0*pre[v+1]/(v+1),
//								(double)1.0*(pre[n]-pre[v-2])/(n-v+2)),(double)1.0*pre[n]/n));
	}
	//fclose(stdin);//fclose(stdout);
	return 0;
}

详细

Test #1:

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

input:

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

output:

6.750000000000
5.833333333333

result:

ok 2 numbers

Test #2:

score: -100
Wrong Answer
time: 72ms
memory: 3896kb

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.666666626930
435670789.666666686535
-661353448.666666626930
608562705.000000000000
296293261.666666686535
319149416.333333313465
571816312.666666626930
223646002.333333343267
39407315.666666664183
383253737.666666686535
-697292126.666666626930
-651679941.000000000000
490276408.33333331346...

result:

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