QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#607042#5505. Great ChaseQHhee004#WA 589ms3916kbC++17907b2024-10-03 13:44:412024-10-03 13:44:48

Judging History

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

  • [2024-10-03 13:44:48]
  • 评测
  • 测评结果:WA
  • 用时:589ms
  • 内存:3916kb
  • [2024-10-03 13:44:41]
  • 提交

answer

#include<iostream>
#include<cmath>
using namespace std;
typedef long long LL;
typedef long double ldb;
const int N=400005;
const ldb eps=1e-9l;
int n,v;
LL standar;
struct People {
	LL s;
	int v;
} A[N];
bool check(ldb t) {
	ldb lowS=-1e13,uprS=1e13;
	for(int i=1; i<=n; i++) {
		if(A[i].s<0) {
			if(A[i].v*t+A[i].s*v>lowS) lowS=A[i].v*t+A[i].s*v; 
		} else {
			if(A[i].s*v-A[i].v*t<uprS) uprS=A[i].s*v-A[i].v*t; 
		}
	}
	return uprS<=lowS;
}
void solve() {
//	printf("%.8Lf\n",1e16l+5e-8l);
	scanf("%d%d",&n,&v);
	for(int i=1; i<=n; i++) {
		scanf("%lld%d",&A[i].s,&A[i].v);
	}
	ldb L=0,R=1e14l*v,ans=0;
	while(R-L>eps) {
		ldb mid=(L+R)/2;
		if(check(mid)) {
			ans=mid;
			if(R-mid<eps)break;
			R=mid;
		}
		else {
			if(mid-L<eps)break;
			L=mid;
		}
	}
	printf("%.8Lf\n",ans);
}
int main() {
	int T;scanf("%d",&T);
	while(T--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3916kb

input:

3
4 9
10 2
-7 2
-6 1
7 1
2 8
-1 7
1 6
2 3
-1000000000000 1
1000000000000 1

output:

38.25000000
1.23076923
3000000000000.00000000

result:

ok 3 numbers

Test #2:

score: -100
Wrong Answer
time: 589ms
memory: 3904kb

input:

10000
200 997007
405524182320 754760
686939601648 419804
687047488212 715566
1446157132 4594
-670522037 4673
763634629282 253755
424307411732 275041
1582708381 8473
-667425982 4622
-522841486 1427
702430907988 460271
1405423646 1060
1497754648 6227
883363410675 723547
56899800372 46435
-810216390 64...

output:

122431385854.29465686
11464312615.55246253
5202715639.83518390
284495631.04772251
9777251206.36106325
183885744.76923077
591049967.14687675
17574028330.40478412
12025157448.90607743
412975327.55555556
965508404.51210149
2081209356.74776629
350183662.67980280
5575125771.79879716
308222275.76435188
98...

result:

wrong answer 1st numbers differ - expected: '145405766328.3491211', found: '122431385854.2946625', error = '0.1580019'