QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#703845 | #8022. Walker | QFshengxiu | WA | 0ms | 3916kb | C++23 | 1.4kb | 2024-11-02 18:40:21 | 2024-11-02 18:40:21 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
double v1,w1,v2,w2,n;
signed main(){
int t;
cin >> t;
while(t--){
cin >> n >> w1 >> v1 >> w2 >> v2;
// cout << v2 << "\n";
double mint=1e9+7;
if(w1>w2){
swap(w1,w2);
swap(v1,v2);
}
// cout << w1 << v1 << w2 << v2 << "\n";
if(w1==0 && w2==n){
cout << n/(v1+v2);
continue;
}
if(w1==0){
cout << (2*n-w2)/(v1+v2);
continue;
}
if(w2==n){
cout << (n+w1)/(v1+v2);
continue;
}
//ww
double x=(w2*v1+n*v1-w1*v2)/(v2+2*v1);
// cout << x << "\n";
// cout << (x+w1)*v2 << " " << (w2+n-2*x)*v1 << "\n";
if(x<=w2){
mint=min(mint,(x+w1)/v1);
}
// cout << mint << "\n";
x=(2*n*v1-w2*v1+w1*v2)/(2*v2+v1);
if(x>=w1){
mint=min(mint,(2*x-w1)/v1);
}
mint=min({mint,(min(n+w1,n+n-w1))/v1,(min(n+w2,n+n-w2))/v2});
// cout << mint << "\n";
//1
mint=min(mint,(w2-w1+2*n)/(v1+v2));
// cout << mint << "\n";
//2
mint=min(mint,(n-w2+w1+n)/(v1+v2));
// cout << mint << "\n";
//3
double t1=(w2+w1)/(v1+v2);
double wz=abs(v1*t1-w1);
mint=min(mint,t1+min((n-wz)/v1,(n-wz)/v2));
// cout << mint << "\n";
//4
t1=(2*n-w1-w2)/(v1+v2);
// cout << t1 << " ";
wz=n-abs(w2+v2*t1-n);
mint=min(mint,t1+min(wz/v1,wz/v2));
cout << fixed << setprecision(6) << mint << "\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3876kb
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: 3864kb
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: 3868kb
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: 3856kb
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: 3872kb
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: 3888kb
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: -100
Wrong Answer
time: 0ms
memory: 3916kb
input:
1 10.0 4.0 0.1 6.0 0.1
output:
80.000000
result:
wrong answer 1st numbers differ - expected: '60.0000000', found: '80.0000000', error = '0.3333333'