QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#743502 | #8022. Walker | Foracy | WA | 0ms | 3844kb | C++20 | 1.0kb | 2024-11-13 19:22:36 | 2024-11-13 19:22:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
double n,a,va,b,vb;
bool check(double t){
double a1 = (va*t - a);
double a2 = (va*t - a) / 2 + a;
double b1 = (vb*t - (n-b));
double b2 = (vb*t - (n-b)) / 2 + (n-b);
if (a1 < 0 || a2 < 0 || b1 < 0 || b2 < 0){
return 0;
}
if (a1+b1 >= n || a1+b2 >= n || a2+b1 >= n || a2+b2 >= n){
return 1;
}
return 0;
}
int main(){
cout << fixed << setprecision(6);
int T;
cin >> T;
while (T--){
cin >> n >> a >> va >> b >> vb;
if (a > b){
swap(a,b);
swap(va,vb);
}
double case1 = max((n-a)/va,(n-b)/vb);
double lo = 0, hi = case1;
while (lo <= hi){
double mid = (lo + hi) / 2;
if (check(mid)){
hi = mid - 0.00000001;
} else{
lo = mid + 0.00000001;
}
}
cout << min({(n+a)/va,(n+b)/vb,lo}) << '\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3844kb
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: 3796kb
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: -100
Wrong Answer
time: 0ms
memory: 3804kb
input:
1 10.0 8.0 10.0 9.0 0.1
output:
1.800000
result:
wrong answer 1st numbers differ - expected: '1.2000000', found: '1.8000000', error = '0.5000000'