QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#509632 | #8022. Walker | Xunwuqishi# | WA | 1ms | 3944kb | C++14 | 1.8kb | 2024-08-08 16:40:07 | 2024-08-08 16:40:07 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define lowbit(x) x & (-x)
#define int long long
#define double long double
const int N = 2e5 + 10;
double INF = 1e9;
int mod = 1e6 + 7;
// int mod = 1e9+7;
// int ways[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};
double n, a, b, av, bv, ans;
void solve()
{
cin >> n >> a >> av >> b >> bv;
if (a > b)
{
swap(a, b);
swap(av, bv);
}
double t;
ans = 4e18l;
ans = min(ans, (n + n - a) / av);
ans = min(ans, (n + n - b) / bv);
ans = min(ans, (a + n) / av);
ans = min(ans, (b + n) / bv);
t = (b - a) / (av + bv);
ans = min(ans, t + max((a + t * av) / av, (n - b + t * bv) / bv));
//ans = min(ans, max((2*a+t*av) / av, (2*(n-b)+t*bv) / bv));
ans = min(ans, max((n - b) / bv, (b + a) / av));
ans = min(ans, max(a / av, (n - b + n - a) / bv));
ans = min(ans, max((n - b) / bv, (b - a + b - a + a) / av));
ans = min(ans, max(a / av, (b - a + b - a + n - b) / bv));
if (a / av > (n - b) / bv)
{
double x = bv * a / av- (n - b);
ans = min(ans, a / av + (n - x) / (av + bv));
}
else
{
double x = av * (n - b) / bv- a;
ans = min(ans, (n - b) / bv + (n - x) / (av + bv));
}
double xx = (a / av + (n + b) / bv) / ((1 / av + 1 / bv) * 2.0);
// double xx = (av * (2.0 * (b - a) + n - b) - a * bv) / (2.0 * (av + bv));
if (xx >= a && xx <= b)
{
ans = min(ans, (2 * xx - a) / av);
}
cout << ans << endl;
}
signed main()
{
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cout << fixed << setprecision(10);
int caset = 1;
cin >> caset;
for (int i = 1; i <= caset; i++)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3916kb
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: 3840kb
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: 1ms
memory: 3944kb
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: 3832kb
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: 3840kb
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: 3904kb
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: 3820kb
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: 3928kb
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: -100
Wrong Answer
time: 0ms
memory: 3884kb
input:
1 10.0 3.0 2.0 7.0 1.0
output:
4.6666666667
result:
wrong answer 1st numbers differ - expected: '4.6000000', found: '4.6666667', error = '0.0144928'