QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#647886 | #8022. Walker | gjlccc | WA | 1ms | 3956kb | C++17 | 1.2kb | 2024-10-17 16:03:16 | 2024-10-17 16:03:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
ld n, p1, v1, p2, v2;
ld js(ld p, ld v, ld l, ld r) { return ((min(p - l, r - p) + (r - l)) / v); }
void solve() {
cin >> n >> p1 >> v1 >> p2 >> v2;
if (p1 > p2) {
swap(v1, v2);
// ld tp1 = n - p1;
// ld tp2 = n - p2;
// p1 = tp1;
// p2 = tp2;
swap(p1, p2);
}
// cout << p1 << " " << p2 << "\n";
ld ans = 1e9 + 10;
// p1
ans = min(ans, max(js(p1, v1, 0, n), js(p2, v2, 0, n)));
// cout << ans << "\n";
// p2
ans = min(ans, max(js(p1, v1, p1, n), js(p2, v2, 0, p2)));
// cout << ans << "\n";
// p3
ld l = p1, r = p2;
ll ti = 60;
while (ti--) {
ld mid = (l + r) / 2;
// cout << mid << "\n";
ld t1 = js(p1, v1, 0, mid);
ld t2 = js(p2, v2, mid, n);
// cout << t1 << " " << t2 << "\n";
ans = min(ans, max(t1, t2));
// cout << ans << "\n";
if (t1 < t2)
l = mid;
else
r = mid;
}
cout << fixed << setprecision(12) << ans << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll t = 1;
cin >> t;
while (t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3856kb
input:
2 10000.0 1.0 0.001 9999.0 0.001 4306.063 4079.874 0.607 1033.423 0.847
output:
5001000.000000000000 3827.837001375516
result:
ok 2 numbers
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3956kb
input:
1 10.0 1.0 10.0 9.0 0.1
output:
10.000000000000
result:
wrong answer 1st numbers differ - expected: '1.1000000', found: '10.0000000', error = '8.0909091'