QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#725297 | #8022. Walker | nnk | WA | 1ms | 3968kb | C++20 | 1.4kb | 2024-11-08 17:01:30 | 2024-11-08 17:01:34 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define N 500005
using namespace std;
void solve()
{
double p1, v1, p2, v2, ans, n;
cin >> n >> p1 >> v1 >> p2 >> v2;
if (p1 > p2) {
swap(p1, p2);
swap(v1, v2);
}
//一个人走完全程
ans = (min(p1, n - p1) + n) / v1;
ans = min(ans, (min(p2, n - p2) + n) / v2);
//相反方向走
ans = min(ans, (n + p1 + (n - p2)) / (v1 + v2));
double tt = min(max((p2 + p1) / v1, (n - p2) / v2), max((n - p1 + n - p2) / v2, p1 / v1)), x, x2;
ans = min(ans, tt);
//相对方向走
tt = (n + p2 - p1) / (v1 + v2);
if (tt * v1 < p1 || tt * v2 < (n - p2));
else ans = min(ans, tt);
//相同方向走
x = (2 * n * v1 + p1 * v2 - p2 * v1) / (v1 + 2 * v2);
if (x >= p1 && x <= p2)
ans = min(ans, (2 * x - p1) / v1);
//else ans = min(ans, max((p2 + p2 - p1) / v1, (n - p2) / v2));
x2 = (n * v1 + p2 * v1 - p1 * v2) / (2 * v1 + v2);
if (x2 >= p1 && x2 <= p2)
ans = min(ans, (n + p2 - 2 * x2) / v2);
// else ans = min(ans, max((p2 - p1 + n - p1) / v2, p1 / v1));
cout<<setiosflags(ios::fixed)<<setprecision(10) << ans << endl;
}
signed main() {
ios::sync_with_stdio(false), cin.tie(nullptr);
int T = 1;
cin >> T;
while (T--) {
solve();
}
return 0;
}
/*
10
3 1
da/ma/ca/k
da/ma/ca/m
a/b/cc
da/ma/h/c
3 1
da/ma/ca/k
da/ma/ca/m
a/b/cc
da/ma/c
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3968kb
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: 0ms
memory: 3856kb
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: 3948kb
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: 1ms
memory: 3848kb
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: 3852kb
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: 3832kb
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: 3704kb
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: 0ms
memory: 3852kb
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: 3940kb
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: 3856kb
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: 0ms
memory: 3856kb
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: 3848kb
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: 0
Accepted
time: 0ms
memory: 3852kb
input:
1 10000.0 1.0 0.001 1.0 0.001
output:
9999000.0000000000
result:
ok found '9999000.0000000', expected '9999000.0000000', error '0.0000000'
Test #14:
score: -100
Wrong Answer
time: 0ms
memory: 3912kb
input:
1 10.0 5.0 1.0 5.0 1.5
output:
6.6666666667
result:
wrong answer 1st numbers differ - expected: '5.0000000', found: '6.6666667', error = '0.3333333'