QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#546883 | #8022. Walker | wzxtsl | WA | 0ms | 3948kb | C++17 | 2.0kb | 2024-09-04 15:25:58 | 2024-09-04 15:25:58 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
//fabs、sqrtl
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define int long long
#define db double
#define PII pair<int,int>
#define For(i,a,n) for(int i=a;i<=n;i++)
#define rof(i,n,a) for(int i=n;i>=a;i--)
#define eps 1e-9
const int N=505,M=505;//点,边
const int mod=998244353,INF=0x3f3f3f3f;//1e9+7,int
void solve(){
double n,p1,v1,p2,v2;
cin>>n>>p1>>v1>>p2>>v2;
//第一种往两边走
if(p1>p2){
swap(p1,p2);
swap(v1,v2);
}//cout<<p1<<"!"<<p2<<"!!";
double t1=p1/v1;
double t2=(n-p2)/v2;
double t=0;
if(t2<t1){
t+=t2;
if(n/v2<=(p1-v1*t2)/v1) t+=n/v2;
else{
if(v2*(p1-v1*t2)/v1>=n-p1){
t+=(p1-v1*t2)/v1;
}else{
t+=(p1-v1*t2)/v1;
t+=min((n-(p1-v1*t2)/v1*v2-p1)/v2,min(min(p2,n-v2*(p1-v1*t2)/v1)/v1,(n-(p1-v1*t2)/v1*v2)/(v1+v2)));
}
}
}else if(t1==t2){
t+=t1;
t+=min(p2/v1,min(n/(v1+v2),(n-p1)/v2));
}else{
t+=t1;
if(n/v1<=(n-p2-v2*t1)/v2) t+=n/v1;
else{
if(v1*(n-p2-v2*t1)/v2>=p2){
t+=(n-p2-v2*t1)/v2;
}else{
t+=(n-p2-v2*t1)/v2;
t+=min((n-(n-p2-v2*t1)/v2*v1)/(v1+v2),min(min(n-p1,n-(n-p2-v2*t1)/v2*v1)/v2,((n-p2-(n-p2-v2*t1)/v2*v1)/v1)));
}
}
}
//第二种一个人走完全程
double tt=0;
tt=min((min(p2,n-p2)+n)/v2,(min(p1,n-p1)+n)/v1);
//cout<<min(t,tt)<<"!"<<endl;
//第三种两人同向走
double ttt=0;
//cout<<(n-p1)/v1<<"!"<<(n-p2/v2)<<endl;
ttt=max((n-p1)/v1,(n-p2)/v2);
ttt=min(ttt,(p2-p1)/(v1+v2)+max(p1/v1,p2/v2));
//cout<<ttt<<"!";
t=min(t,min(tt,ttt));
cout<<fixed<<setprecision(16)<<endl;
cout<<t<<endl;
}
signed main(){
int T=1;
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: 3888kb
input:
2 10000.0 1.0 0.001 9999.0 0.001 4306.063 4079.874 0.607 1033.423 0.847
output:
5001000.0000000000000000 3827.8370013755161381
result:
ok 2 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
1 10.0 1.0 10.0 9.0 0.1
output:
1.1000000000000001
result:
ok found '1.1000000', expected '1.1000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3948kb
input:
1 10.0 8.0 10.0 9.0 0.1
output:
1.2000000000000000
result:
ok found '1.2000000', expected '1.2000000', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
1 10.0 8.0 0.1 9.0 10
output:
1.1000000000000001
result:
ok found '1.1000000', expected '1.1000000', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3696kb
input:
1 10.0 2.0 0.1 3.0 10
output:
1.3000000000000000
result:
ok found '1.3000000', expected '1.3000000', error '0.0000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
1 10.0 9.0 0.1 8.0 10.0
output:
1.2000000000000000
result:
ok found '1.2000000', expected '1.2000000', error '0.0000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
1 10.0 4.0 0.1 6.0 0.1
output:
60.0000000000000000
result:
ok found '60.0000000', expected '60.0000000', error '0.0000000'
Test #8:
score: -100
Wrong Answer
time: 0ms
memory: 3888kb
input:
1 10.0 4.5 0.1 6.0 0.1
output:
55.0000000000000000
result:
wrong answer 1st numbers differ - expected: '57.5000000', found: '55.0000000', error = '0.0434783'