QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#298333#5505. Great Chaseushg8877AC ✓990ms10020kbC++14657b2024-01-06 00:04:322024-01-06 00:04:32

Judging History

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

  • [2024-01-06 00:04:32]
  • 评测
  • 测评结果:AC
  • 用时:990ms
  • 内存:10020kb
  • [2024-01-06 00:04:32]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MP make_pair
mt19937 rnd(time(0));
const int MAXN=4e5+5;
int n,v;
ll p[MAXN],a[MAXN]; 
bool check(long double x){
	long double le=-1e18,ri=1e18;
	for(int i=1;i<=n;i++) 
		if(p[i]<0) le=max(le,p[i]+a[i]*x);
		else ri=min(ri,p[i]-a[i]*x);
	return le>=ri;
}
void solve(){
	cin>>n>>v;
	for(int i=1;i<=n;i++) cin>>p[i]>>a[i];
	long double l=0,r=1e12,mid;
	for(int i=1;i<=100;i++){
		mid=(l+r)*0.5;
		if(check(mid)) r=mid;
		else l=mid;
	}
	cout<<setprecision(12)<<l*v<<endl;
}
int main(){
	ios::sync_with_stdio(false);
	int _;cin>>_;
	while(_--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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.25
1.23076923077
3e+12

result:

ok 3 numbers

Test #2:

score: 0
Accepted
time: 562ms
memory: 5772kb

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:

145405766328
16414958969.7
5202715639.84
321977234.156
45384199210.2
183885744.769
1708925225.23
89786664971.6
13924365606.3
412975327.556
965508404.512
4703493416.29
352961619.381
5575125771.8
341191687
985544508.333
1370541507.65
143194575.078
8728055566.82
28694043964
1368121972.76
4397065530.38
...

result:

ok 10000 numbers

Test #3:

score: 0
Accepted
time: 944ms
memory: 8016kb

input:

93
15435 968117
4196666 184
-5069875 255
-9782648 980
-1978138 176
9333323 764
-4323540 12
-8442049 319
-5371878 137
2881306 10
-4050629 133
-4659099 59
-5189169 320
-2256647 99
-3686648 37
1059255 33
-223142 20
8040933 408
8407764 705
694547 38
-7913614 746
-3573355 132
5919585 189
-3756662 94
-795...

output:

189662921.364
197971181.333
997533531.738
6439673170.67
993821598111
22727977326.4
34702455207.5
677770533.93
46631726884
5446481867.13
11336247450.3
4409370840.44
15681606050.6
14986614231.5
1025909753.14
18994454579.8
105092139113
25758936826
252231500.769
50720505867.3
405718165
24553806495.6
201...

result:

ok 93 numbers

Test #4:

score: 0
Accepted
time: 815ms
memory: 10020kb

input:

5
400000 999972
172811492468 106699
171900177092 102097
194121748377 184014
190302947556 172722
183121572232 149212
196566712700 190884
171376795991 99358
522927044000 159597
-129031052077 34395
189422320931 170012
-275879974024 638546
408864707565 98475
-106703244806 368801
192128798630 178213
2915...

output:

519985220220
511413015797
424240880534
518849481156
1.88249698819e+12

result:

ok 5 numbers

Test #5:

score: 0
Accepted
time: 990ms
memory: 9204kb

input:

38
16668 999947
-3844782803 511
-210897941456 464872
618726004990 714384
-954596898686 225256
96675744 1148
-1515974078 11375
-206213840984 706184
306078847 3947
-474818331950 391451
-616022698917 561244
123378707 1540
-640636592655 406006
459201391325 908506
-733249583 5719
496163273 6238
619876911...

output:

89670748253
98630840901.5
29393530999.9
50801000771
39668001027.3
467846478226
30789914370.6
23151476830.9
51606123416.6
151713060002
100944679010
766785664078
39969642788.1
62341065938.4
323981604329
115228655021
52894567562.2
83882295665.6
20963769176.9
117523885638
373045000062
198169469456
81645...

result:

ok 38 numbers