QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#545929#8022. WalkerwzxtslWA 0ms3856kbC++171.6kb2024-09-03 18:16:012024-09-03 18:16:02

Judging History

你现在查看的是最新测评结果

  • [2024-09-03 18:16:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3856kb
  • [2024-09-03 18:16:01]
  • 提交

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)));
            }
        }
    }
    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: 3852kb

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: 3856kb

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: -100
Wrong Answer
time: 0ms
memory: 3656kb

input:

1
10.0 8.0 10.0 9.0 0.1

output:


1.8000000000000000

result:

wrong answer 1st numbers differ - expected: '1.2000000', found: '1.8000000', error = '0.5000000'