QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#378985#8022. Walkercomeintocalm#TL 0ms0kbC++17973b2024-04-06 15:38:382024-04-06 15:38:38

Judging History

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

  • [2024-04-06 15:38:38]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-04-06 15:38:38]
  • 提交

answer

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

const db eps = 1e-13;
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 ("%.13lf\n", ans);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

2
10000.0 1.0 0.001 9999.0 0.001
4306.063 4079.874 0.607 1033.423 0.847

output:


result: