QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#703796#8022. WalkerQFshengxiuWA 0ms3920kbC++231.3kb2024-11-02 18:31:302024-11-02 18:31:31

Judging History

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

  • [2024-11-02 18:31:31]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3920kb
  • [2024-11-02 18:31:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
double v1,w1,v2,w2,n;
signed main(){
	int t;
	cin >> t;
	while(t--){
		cin >> n >> w1 >> v1 >> w2 >> v2;
//		cout << v2 << "\n";
		double mint=1e9+7;
		if(w1>w2){
			swap(w1,w2);
			swap(v1,v2);
		}
//		cout << w1 << v1 << w2 << v2 << "\n";
		if(w1==0 && w2==n){
			cout << n/(v1+v2);
			continue;
		}
		if(w1==0){
			cout << (2*n-w2)/(v1+v2);
			continue;
		}
		if(w2==n){
			cout << (n+w1)/(v1+v2);
			continue;
		}
		//ww
		double x=(w2*v1+n*v1-w1*v2)/(v2+2*v1);
//		cout << x << "\n";
//		cout << (x+w1)*v2 << " " << (w2+n-2*x)*v1 << "\n";
		if(x<=w2){
			mint=min(mint,(x+w1)/v1);
		}
//		cout << mint << "\n";
		x=(2*n*v1-w2*v1+w1*v2)/(2*v2+v1);
		if(x>=w1){	
			mint=min(mint,(2*x-w1)/v1);
		}
		mint=min({mint,n/v1,n/v2}); 
//		cout << mint << "\n";
		//1
		mint=min(mint,(w2-w1+n)/(v1+v2));
//		cout << mint << "\n";
		//2
		mint=min(mint,(n-w2+w1+n)/(v1+v2));
//		cout << mint << "\n";
		//3
		double t1=(w2+w1)/(v1+v2);
		double wz=abs(v1*t1-w1);
		mint=min(mint,t1+min((n-wz)/v1,(n-wz)/v2));
//		cout << mint << "\n";
		//4
		t1=(2*n-w1-w2)/(v1+v2);
//		cout << t1 << " ";
		wz=n-abs(w2+v2*t1-n);
		mint=min(mint,t1+min(wz/v1,wz/v2));
		cout << fixed << setprecision(6) << mint << "\n";
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3856kb

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

input:

1
10.0 1.0 10.0 9.0 0.1

output:

1.000000

result:

wrong answer 1st numbers differ - expected: '1.1000000', found: '1.0000000', error = '0.0909091'