QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#707715 | #8022. Walker | xiey | WA | 15ms | 3948kb | C++20 | 1.2kb | 2024-11-03 17:11:49 | 2024-11-03 17:11:49 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
double n, p1, v1, p2, v2;
bool check(double t)
{
double a = p1;
double b = p2 - p1;
double c = n - p2;
double x1,x2;
if(t*v1-2*a>=0)
{
x1=a+max(t*v1-2*a,(t*v1-a)/2);
}
else
{
if(t*v1-a>=0)
{
x1=a+(t*v1-a)/2;
}
else
{
x1=0;
}
}
if(t*v2-2*c>=0)
{
x2=n-(max(t*v2-2*c,(t*v2-c)/2)+c);
}
else
{
if(t*v2-c>=0)
{
x2=n-((t*v2-c)/2+c);
}
else
{
x2=n;
}
}
if(x2<=x1)
{
return 1;
}
else
{
return 0;
}
}
void solve()
{
scanf("%lf %lf %lf %lf %lf", &n, &p1, &v1, &p2, &v2);
if (p1 > p2)
{
swap(p1, p2);
swap(v1, v2);
}
double l = 0, r = 1e8;
while (r - l > 1e-8)
{
double mid = (l + r) / 2;
if (check(mid))
r = mid;
else
l = mid;
}
printf("%.6lf\n", l);
}
int main()
{
int t = 1;
scanf("%d", &t);
while (t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3848kb
input:
2 10000.0 1.0 0.001 9999.0 0.001 4306.063 4079.874 0.607 1033.423 0.847
output:
5001000.000000 3827.837001
result:
ok 2 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3948kb
input:
1 10.0 1.0 10.0 9.0 0.1
output:
1.100000
result:
ok found '1.1000000', expected '1.1000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
1 10.0 8.0 10.0 9.0 0.1
output:
1.200000
result:
ok found '1.2000000', expected '1.2000000', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3944kb
input:
1 10.0 8.0 0.1 9.0 10
output:
1.100000
result:
ok found '1.1000000', expected '1.1000000', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
1 10.0 2.0 0.1 3.0 10
output:
1.300000
result:
ok found '1.3000000', expected '1.3000000', error '0.0000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
1 10.0 9.0 0.1 8.0 10.0
output:
1.200000
result:
ok found '1.2000000', expected '1.2000000', error '0.0000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
1 10.0 4.0 0.1 6.0 0.1
output:
60.000000
result:
ok found '60.0000000', expected '60.0000000', error '0.0000000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
1 10.0 4.5 0.1 6.0 0.1
output:
57.500000
result:
ok found '57.5000000', expected '57.5000000', error '0.0000000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
1 10.0 1.0 1.0 8.0 1.0
output:
6.500000
result:
ok found '6.5000000', expected '6.5000000', error '0.0000000'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
1 10.0 3.0 2.0 7.0 1.0
output:
4.600000
result:
ok found '4.6000000', expected '4.6000000', error '0.0000000'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3940kb
input:
1 10.0 6.0 2.0 7.0 1.0
output:
3.666667
result:
ok found '3.6666670', expected '3.6666667', error '0.0000001'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
1 10.0 1.0 1.0 9.0 1.0
output:
6.000000
result:
ok found '6.0000000', expected '6.0000000', error '0.0000000'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3916kb
input:
1 10000.0 1.0 0.001 1.0 0.001
output:
9999000.000000
result:
ok found '9999000.0000000', expected '9999000.0000000', error '0.0000000'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
1 10.0 5.0 1.0 5.0 1.5
output:
5.000000
result:
ok found '5.0000000', expected '5.0000000', error '0.0000000'
Test #15:
score: -100
Wrong Answer
time: 15ms
memory: 3816kb
input:
10000 4306.063 4079.874 0.607 1033.423 0.847 8967.336 8026.500 0.398 283.019 0.876 9568.147 4481.616 0.405 800.114 0.684 9867.264 6184.040 0.312 9853.164 0.641 3344.364 730.612 0.539 1305.868 0.947 9336.180 3672.113 0.773 432.686 0.312 1468.243 59.762 0.840 1438.446 0.827 1355.133 1096.314 0.373 109...
output:
3827.837001 7999.364992 12559.335802 15415.544462 2637.698520 9931.041518 934.494301 4326.949062 5754.032890 2847.427157 10975.323628 2902.179104 24531.536364 6278.103555 1030.000000 10734.395644 1005.077029 24249.746781 9878.009946 22899.259259 12409.897778 33365.476190 3153.058733 11691.597625 201...
result:
wrong answer 4th numbers differ - expected: '15371.5507020', found: '15415.5444620', error = '0.0028620'