QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#697490 | #8022. Walker | Orthos | WA | 0ms | 3948kb | C++17 | 1.4kb | 2024-11-01 14:22:11 | 2024-11-01 14:22:12 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int t;
double n,p1,v1,p2,v2;
void solve(){
scanf("%lf%lf%lf%lf%lf",&n,&p1,&v1,&p2,&v2);
// cin>>n>>p1>>v1>>p2>>v2;
if(p1>=p2){
swap(p1,p2);
swap(v1,v2);
}
double t1,t2,t3,t4;
t1=(p1+2*n-p2)/(v1+v2);
if(p1>0&&p2<n){
t2=min((2*n-p1)/v1,(2*n-p2)/v2);
}
else if(p1==0){
double tp=(p2-p1)/v1;
if(v2*tp>=n-p2){
t2=min(tp,(2*n-p2)/(v1+v2));
}
else{
t2=min(n/v1,(n-p2)/v2);
}
}
if(p1>0&&p2<n){
t3=min((n+p1)/v1,(p2+n)/v2);
}
else if(p2==n){
double tp=(p2-p1)/v2;
if(v1*tp>=p1){
t3=min(tp,(n+p1)/(v1+v2));
}
else{
t3=min(p2/v2,(p1)/v1);
}
}
if(p1>0&&p2<n){
t4=max(min((2*n-p1)/v1,p2/v2),min((n-p1)/v1,(n+p2)/v2));
}
else if(p1==0&&p2==n){
t4=n/(v1+v2);
}
else if(p1==0){
t4=min(n/v1,(n+p2)/v2);
}
else if(p2==n){
t4=min((2*n-p1)/v1,p2/v2);
}
// cout<<t1<<"\n"<<t2<<"\n"<<t3<<"\n"<<t4<<"\n";
printf("%.10lf\n",min({t1,t2,t3,t4}));
}
int main(){
// ios::sync_with_stdio(false);
// cin.tie(0);
// cout.tie(0);
cin>>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: 3904kb
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: 3908kb
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: 3892kb
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: 3876kb
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: 3948kb
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: 3896kb
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: 3860kb
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: -100
Wrong Answer
time: 0ms
memory: 3892kb
input:
1 10.0 4.5 0.1 6.0 0.1
output:
60.0000000000
result:
wrong answer 1st numbers differ - expected: '57.5000000', found: '60.0000000', error = '0.0434783'