QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#378978#8022. Walkercomeintocalm#WA 1ms3916kbC++17975b2024-04-06 15:35:282024-04-06 15:35:29

Judging History

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

  • [2024-04-06 15:35:29]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3916kb
  • [2024-04-06 15:35:28]
  • 提交

answer

#include <bits/stdc++.h>
#define LL long long
#define db double
using namespace std;

const db eps = 1e-12;
int T;
db n, p[2], v[2];

db calc (int x, db l, db r) {
	return (r - l + min (p[x] - l, r - p[x])) / v[x];
}

int main() {
	int i,j,k;
	scanf ("%d", &T);
	while (T--) {
		scanf ("%lf%lf%lf%lf%lf", &n, &p[0], &v[0], &p[1], &v[1]);
		if (p[0] > p[1]) swap (p[0], p[1]), swap (v[0], v[1]);
		db ans = min (calc (0, 0, n), calc (1, 0, n));
		//ans = min (ans, max (0, 0, p[1]))
		//cout << n << endl;
		//cout << calc (0, 0, n) << endl;
		db L = p[0], R = p[1];
		while (L + eps < R) {
			db fm = (R - L) / 3.0, m1 = L + fm, m2 = R - fm;
			db a1 = max (calc (0, 0, m1), calc (1, m1, n));
			db a2 = max (calc (0, 0, m2), calc (1, m2, n));
			ans = min (ans, a1);
			ans = min (ans, a2);
			if (a1 < a2) R = m2;
			else L = m1;
		}
		//ans = min (ans, max (calc (0, 0, L), calc (1, L, n)));
		printf ("%.10lf\n", ans);
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3864kb

input:

2
10000.0 1.0 0.001 9999.0 0.001
4306.063 4079.874 0.607 1033.423 0.847

output:

5001000.0000000000
3827.8370013755

result:

ok 2 numbers

Test #2:

score: 0
Accepted
time: 1ms
memory: 3916kb

input:

1
10.0 1.0 10.0 9.0 0.1

output:

1.1000000000

result:

ok found '1.1000000', expected '1.1000000', error '0.0000000'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3872kb

input:

1
10.0 8.0 10.0 9.0 0.1

output:

1.2000000000

result:

ok found '1.2000000', expected '1.2000000', error '0.0000000'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

1
10.0 8.0 0.1 9.0 10

output:

1.1000000000

result:

ok found '1.1000000', expected '1.1000000', error '0.0000000'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3848kb

input:

1
10.0 2.0 0.1 3.0 10

output:

1.3000000000

result:

ok found '1.3000000', expected '1.3000000', error '0.0000000'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3880kb

input:

1
10.0 9.0 0.1 8.0 10.0

output:

1.2000000000

result:

ok found '1.2000000', expected '1.2000000', error '0.0000000'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3848kb

input:

1
10.0 4.0 0.1 6.0 0.1

output:

60.0000000000

result:

ok found '60.0000000', expected '60.0000000', error '0.0000000'

Test #8:

score: 0
Accepted
time: 1ms
memory: 3844kb

input:

1
10.0 4.5 0.1 6.0 0.1

output:

57.5000000000

result:

ok found '57.5000000', expected '57.5000000', error '0.0000000'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3872kb

input:

1
10.0 1.0 1.0 8.0 1.0

output:

6.5000000000

result:

ok found '6.5000000', expected '6.5000000', error '0.0000000'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3912kb

input:

1
10.0 3.0 2.0 7.0 1.0

output:

4.6000000000

result:

ok found '4.6000000', expected '4.6000000', error '0.0000000'

Test #11:

score: 0
Accepted
time: 1ms
memory: 3804kb

input:

1
10.0 6.0 2.0 7.0 1.0

output:

3.6666666667

result:

ok found '3.6666667', expected '3.6666667', error '0.0000000'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

1
10.0 1.0 1.0 9.0 1.0

output:

6.0000000000

result:

ok found '6.0000000', expected '6.0000000', error '0.0000000'

Test #13:

score: -100
Wrong Answer
time: 0ms
memory: 3848kb

input:

1
10000.0 1.0 0.001 1.0 0.001

output:

10001000.0000000000

result:

wrong answer 1st numbers differ - expected: '9999000.0000000', found: '10001000.0000000', error = '0.0002000'