QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#649337#8242. V-DiagramAa#WA 1ms5984kbC++17720b2024-10-17 22:52:552024-10-17 22:52:56

Judging History

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

  • [2024-10-17 22:52:56]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5984kb
  • [2024-10-17 22:52:55]
  • 提交

answer

#include <iostream>
#include <algorithm>
using namespace std;
const double INF=1e18;
int n;
int a[300010];
double s[300010];
bool check(double mid){
	for(int i=1;i<=n;i++)
		s[i]=s[i-1]+(double)a[i]-mid;
	double mi=INF;
	for(int i=2;i<=n;i++){
		if(a[i]==a[i-1]){
			mi=INF;
			continue;
		}
		else if(a[i]<a[i-1]) mi=min(mi,s[i-2]);
		else if(s[i]-mi>=0) return true;
	}
	return false;
}
signed main(){
	int t;
	scanf("%d",&t);
	while(t--){
		double l=0,r=0;
		scanf("%d",&n);
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
			r=max(r,(double)a[i]);
		}
		while(r-l>1e-8){
			double mid=(l+r)/2;
			if(check(mid)) l=mid;
			else r=mid;
		}
		printf("%.20lf\n",l);
	}
	return 0;
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5984kb

input:

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

output:

6.74999999813735485077
5.83333332650363445282

result:

wrong answer 2nd numbers differ - expected: '5.8333333', found: '5.8333333', error = '0.0000000'