QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#546944#8022. WalkerwzxtslWA 0ms3928kbC++171.2kb2024-09-04 16:07:262024-09-04 16:07:26

Judging History

This is the latest submission verdict.

  • [2024-09-04 16:07:26]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3928kb
  • [2024-09-04 16:07:26]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define int long long
#define double long 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
double n,p1,v1,p2,v2;
double ok(double t){
    double d1=max((t-p1/v1)*v1/2,(t-2*p1/v1)*v1);
    double d2=max((t-(n-p2)/v2)/2*v2,(t-2*(n-p2)/v2)*v2);
    if(d1+d2>=p2-p1) return true;
    else return false;
}
void solve(){
    cin>>n>>p1>>v1>>p2>>v2;
    if(p1>p2){
        swap(p1,p2);
        swap(v1,v2);
    }
    double t=0;
    t=min((min(n-p2,p2)+n)/v2,(min(n-p1,p1)+n)/v1);
    t=min(t,max((n-p1)/v1,(p2/v2)));
    double l=0;
    double r=1e18;
    double mid=0;
    while(r-l>eps){
        mid=(l+r)/2;
        if(ok(mid)){
            t=min(t,mid);
            r=mid;
        }else{
            l=mid;
        }
    }
    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: 3868kb

input:

2
10000.0 1.0 0.001 9999.0 0.001
4306.063 4079.874 0.607 1033.423 0.847

output:


5001000.0000000001973604

3827.8370013756464532

result:

ok 2 numbers

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3928kb

input:

1
10.0 1.0 10.0 9.0 0.1

output:


1.0447761199699281

result:

wrong answer 1st numbers differ - expected: '1.1000000', found: '1.0447761', error = '0.0502035'