QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#18112 | #2267. Jewelry Size | cccpy | WA | 3ms | 4324kb | C++11 | 1.1kb | 2022-01-16 11:29:30 | 2022-05-04 17:06:47 |
Judging History
answer
#include<bits/stdc++.h>
#define db double
#define MAX 1005
using namespace std;
const double eps=1e-8;
const double pi=acos(-1);
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[i])/(tx));
if(type==1) ret+=acos((tx-b[n])/tx);
else ret+=2*pi-acos((tx-b[n])/tx);
// if(type==2) printf("%.8lf %.8lf %.8lf\n",x,ret,2*pi);
// if(x==94723.6448403) cout<<ret<<endl;
if(abs(ret-2*pi)<=1e-4) type==1?ret1=x:ret2=x;
if(type==1){
if(ret<=2*pi) return 1;
return 0;
}else{
if(ret-2*pi>=1e-6) 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(){
// freopen("1.in","r",stdin);
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%lf",&a[i]);
sort(a+1,a+1+n);
for(int i=1;i<=n;i++) b[i]=a[i]*a[i];
ans=min(ck(1),ck(2));
printf("%.8lf",ans);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 4320kb
input:
5 3 1 6 1 7
output:
3.54440435
result:
ok found '3.5444044', expected '3.5444044', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 4212kb
input:
3 500 300 400
output:
250.00000001
result:
ok found '250.0000000', expected '250.0000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 1ms
memory: 4320kb
input:
8 2000 3000 4000 2000 3000 4000 2000 3000
output:
3780.97412060
result:
ok found '3780.9741206', expected '3780.9741206', error '0.0000000'
Test #4:
score: -100
Wrong Answer
time: 3ms
memory: 4324kb
input:
10 602 67 67 67 67 67 67 67 67 67
output:
99999999.99999999
result:
wrong answer 1st numbers differ - expected: '3003.1398170', found: '100000000.0000000', error = '33297.4829528'