QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#879682 | #8022. Walker | ucup-team902 | WA | 1ms | 3968kb | C++20 | 680b | 2025-02-02 10:38:39 | 2025-02-02 10:38:39 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int T;
double n,p1,v1,p2,v2,ans;
int main(){
cin>>T;
while(T--){
scanf("%lf%lf%lf%lf%lf",&n,&p1,&v1,&p2,&v2);
if (p1>p2){
swap(p1,p2);
swap(v1,v2);
}
ans = min(min((min(p1,n-p1)+n)/v1,(min(p2,n-p2)+n)/v2),
max((n-p1)/v1,p2/v2));
double l = 0,r = 1e9,t3=1e9;
for(int i=1;i<=100;++i){
double t = (r+l)/2;
double s = v1*t+v2*t;
//v1*t
double lef=max(v1*t-2*p1,(v1*t-p1)/2),rig=max(v2*t-2*(n-p2),(v2*t-(n-p2))/2);//使t时间内a在p12间跑的与b在p12间跑的最大
if(lef+rig>=p2-p1)r=t,t3=t;//如果可覆盖
else l=t;
}
printf("%.10lf\n",min(ans,t3));
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3840kb
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: -100
Wrong Answer
time: 1ms
memory: 3968kb
input:
1 10.0 1.0 10.0 9.0 0.1
output:
1.0447761194
result:
wrong answer 1st numbers differ - expected: '1.1000000', found: '1.0447761', error = '0.0502035'