QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#18091 | #2267. Jewelry Size | cccpy | WA | 3ms | 4072kb | C++11 | 860b | 2022-01-16 10:58:05 | 2022-05-04 17:04:05 |
Judging History
answer
#include<bits/stdc++.h>
#define db double
#define pi acos(-1)
#define MAX 1005
using namespace std;
const double eps=1e-9;
const long long inf=1e8;
int n;
db a[MAX],b[MAX],ans,ret1,ret2;
bool check(double x,int type){
double ret=0,tx=2*x*x;
for(int i=1;i<=n-1;i++)
ret+=acos((tx-b[n])/tx);
if(type==1) ret+=acos((tx-b[n])/tx);
else ret+=2*pi-acos((tx-b[n])/tx);
if(abs(ret-2*pi)<=1e-3) 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]),b[i]=a[i]*a[i];
sort(a+1,a+1+n);
ans=min(ck(1),ck(2));
printf("%.8lf",ans);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 4072kb
input:
5 3 1 6 1 7
output:
5.95455566
result:
wrong answer 1st numbers differ - expected: '3.5444044', found: '5.9545557', error = '0.6799877'