QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#617977 | #8022. Walker | Okuchiri | WA | 16ms | 3924kb | C++20 | 2.7kb | 2024-10-06 17:58:05 | 2024-10-06 17:58:07 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 998244353
using namespace std;
ll cnt=0;
ld n,a,b,v1,v2;
void work()
{
cnt++;
cin>>n>>a>>v1>>b>>v2;
if(cnt==36)cout<<v2<<'\n';
if(a>b)
{
swap(a,b);
swap(v1,v2);
}
ld a1=a,b1=n-b;
ld ans=min((a+n)/v1,(b+n)/v2);
ans=min({(n-a+n)/v1,(n-b+n)/v2,ans});
ans=min(ans, max(a/v1, min((2*(b-a)+n-b)/v2,(2*(n-b)+b-a)/v2)));
ans=min(ans, max((n-b)/v2,min((2*a+b-a)/v1,(2*(b-a)+a)/v1)));
if(2*a1<=n-2*b1)
{
ld x=(2*v1*b1+(b-a1)*v1-v2*a1)/(2*v2+v1);
if(x>=0&&x<=a1)
{
ans=min(ans,(a1+2*x)/v1);
}
ans=min(ans,max(3*a1/v1,(2*b1+b-2*a1)/v2));
x=(2*b1*v1+(b-a1)*v1-2*a1*v2)/(v1+v2);
if(x>=a1&&x<=b-a-b1)
{
ans=min(ans,(2*a1+x)/v1);
}
ans=min(ans,max(3*b1/v2,(2*a1+b-a-b1)/v1));
x=(v1*b1+2*(b-a1)*v1-2*a1*v2)/(v2+2*v1);
if(x>=b-a-b1&&x<=b-a)
{
ans=min(ans,(2*a1+x)/v1);
}
}
else if(a+a1<=b&&n-2*b1>=a)
{
ld x=(2*v1*b1+(b-a1)*v1-v2*a1)/(2*v2+v1);
if(x>=0&&x<=b-a-b1)
{
ans=min(ans,(a1+2*x)/v1);
}
ans=min(ans,max(3*b1/v2,(2*(b-a-b1)+a)/v1));
x=(v1*b1+2*(b-a1)*v1-v2*a1)/(2*v2+2*v1);
if(x>=b-a-b1&&x<=a1)
{
ans=min(ans,(a1+2*x)/v1);
}
ans=min(ans,max(3*a1/v1,(2*(b-2*a1)+b1)/v2));
x=(v1*b1+2*(b-a1)*v1-2*a1*v2)/(v2+2*v1);
if(x>=a1&&x<=b-a)
{
ans=min(ans,(x+2*a1)/v1);
}
}
else if(b-b1>=a)
{
ld x=(2*v1*b1+v1*(b-a)-a1*v2)/(2*v2+v1);
if(x>=0&&x<=b-a-b1)
{
ans=min(ans,(2*x+a1)/v1);
}
ans=min(ans,max((2*(b-a-b1)+a1)/v1,3*b1/v2));
x=(v1*b1+2*(b-a)*v1-v2*a1)/(2*v2+2*v1);
if(x>=b-a-b1&&x<=b-a)
{
ans=min(ans,(2*x+a1)/v1);
}
}
else if(a1*2<=b)
{
ld x=(v1*b1+2*v1*(b-a)-a1*v2)/(2*v2+v1);
if(x>=0&&x<=a1)
{
ans=min(ans,(2*x+a1)/v1);
}
ans=min(ans,max(3*a1/v1,(2*(b-2*a1)+b1)/v2));
x=(v1*b1+2*(b-a)*v1-2*v2*a1)/(v2+2*v1);
if(x>=a1&&x<=b-a)
{
ans=min(ans,(2*a1+x)/v1);
}
}
else
{
ld x=(v1*b1+2*(b-a)*v1-v2*a1)/(2*v2+2*v1);
if(x>=0&&x<=b-a)ans=min(ans,(2*x+a1)/v1);
}
ans=min(ans,max(b/v2,(n-a)/v1));
cout<<fixed<<setprecision(10)<<ans<<'\n';
}
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int T=1;
cin>>T;
while(T--)
{
work();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3812kb
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: 3812kb
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: 3832kb
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: 0ms
memory: 3884kb
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: 3808kb
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: 3808kb
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: 3820kb
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: 3776kb
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: 3916kb
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: 3924kb
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: 3820kb
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: 3920kb
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: 3828kb
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: 0
Accepted
time: 0ms
memory: 3804kb
input:
1 10.0 5.0 1.0 5.0 1.5
output:
5.0000000000
result:
ok found '5.0000000', expected '5.0000000', error '0.0000000'
Test #15:
score: -100
Wrong Answer
time: 16ms
memory: 3892kb
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.8370013755 7999.3649921507 12559.3358024691 15371.5507020281 2637.6985195155 9931.0415175376 934.4943011398 2939.1796246649 5754.0328898744 2847.4271570014 10975.3236282195 2180.2786069652 23747.0454545455 6278.1035548686 872.3977055449 10734.3956442831 1005.0770288858 20225.1630901288 9878.009...
result:
wrong answer 36th numbers differ - expected: '5767.1781346', found: '0.6120000', error = '0.9998939'