QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#18084#2267. Jewelry Sizeccpy#TL 0ms0kbC++11896b2022-01-16 10:43:562022-05-04 17:03:26

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-04 17:03:26]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2022-01-16 10:43:56]
  • 提交

answer

#include<bits/stdc++.h>
#define db double
#define pi acos(-1)
#define MAX 1005
using namespace std;
const double eps=1e-10;
const long long inf=1e10;
int n;
db a[MAX],ans,ret1,ret2;
bool check(double x,int type){
	double ret=0;
	for(int i=1;i<=n-1;i++)
		ret+=acos((2*x*x-a[i]*a[i])/(2*x*x));
	if(type==1) ret+=acos((2*x*x-a[n]*a[n])/(2*x*x));
	else ret+=2*pi-acos((2*x*x-a[n]*a[n])/(2*x*x));
	if(abs(ret-2*pi)<=1e-5) type==1?ret1=x:ret2=x;
	if(ret>=2*pi) return 0;
	return 1;
}
double ck(int type){
	double l=a[n]/2,r;
	r=inf;
	type==1?ret1=inf:ret2=inf;
	while(l<r-eps){
		double mid=(l+r)/2;
		if(check(mid,type)) type==1?r=mid:l=mid;
		else type==1?l=mid:r=mid;
	}
	return type==1?ret1:ret2;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lf",&a[i]);
	sort(a+1,a+1+n);
	ans=min(ck(1),ck(2));
	check(3003.13981697,2);
	printf("%.8lf",ans);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

5
3 1 6 1 7

output:


result: