QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#18136#2267. Jewelry Sizelaihaochen#WA 2ms2500kbC++17816b2022-01-16 14:52:562022-05-04 17:11:34

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:11:34]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:2500kb
  • [2022-01-16 14:52:56]
  • 提交

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;
}

详细

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'