QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#18136 | #2267. Jewelry Size | laihaochen# | WA | 2ms | 2500kb | C++17 | 816b | 2022-01-16 14:52:56 | 2022-05-04 17:11:34 |
Judging History
answer
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
const int N = 1005;
const double PI = acos(-1), eps = 1e-9;
int n;
double maxn, a[N];
bool check (bool opt, double r) {
double res = 0;
for (int i = 1; i <= n; i++) {
res += asin(a[i] / (2 * r));
}
if (opt) {
return res - PI > -eps;
} else {
return 2 * asin(maxn / (2 * r)) - res > -eps;
}
}
double bs (bool opt, double l, double r) {
while (r - l >= eps) {
double mid = (l + r) / 2;
if (check(opt, mid)) {
l = mid;
} else {
r = mid;
}
}
return check(opt, l) ? l : 1e7;
}
int main() {
scanf ("%d", &n);
for (int i = 1; i <= n; i++) {
scanf ("%lf", &a[i]);
maxn = max (maxn, a[i]);
}
printf ("%.8lf\n", min(bs(1, maxn / 2, 1e7), bs(0, maxn / 2, 1e7)));
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 2360kb
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: 2ms
memory: 2396kb
input:
3 500 300 400
output:
250.00000000
result:
ok found '250.0000000', expected '250.0000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 1ms
memory: 2280kb
input:
8 2000 3000 4000 2000 3000 4000 2000 3000
output:
3780.97412172
result:
ok found '3780.9741217', expected '3780.9741206', error '0.0000000'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 2500kb
input:
10 602 67 67 67 67 67 67 67 67 67
output:
3003.14879449
result:
wrong answer 1st numbers differ - expected: '3003.1398170', found: '3003.1487945', error = '0.0000030'