QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#630720#4096. 코딩 테스트Matutino36 829ms33076kbC++172.7kb2024-10-11 20:08:242024-10-11 20:08:24

Judging History

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

  • [2024-10-11 20:08:24]
  • 评测
  • 测评结果:36
  • 用时:829ms
  • 内存:33076kb
  • [2024-10-11 20:08:24]
  • 提交

answer

#include<bits/stdc++.h>
#define reg register
#define int long long
inline int min(reg int x,reg int y){return x<y?x:y;}
inline bool cmin(reg int &x,reg int y){return x>y?x=y,1:0;}
const int N=5e5+10,INF=1e18;
int n,m,a[N],b[N],idx,rt[N],lim[N];
struct Line{
	int k,b;
	inline int operator()(const int &A)const{return k*A+b;}
	inline Line operator+(const Line &A)const{return {k+A.k,b+A.b};}
}tmp,tmp2;
struct Node{Line pre,suf,sum,mn; int t;}tr[N<<2];
int ls[N<<5],rs[N<<5];
inline int upd(reg Line &A,reg Line B,reg int x){
	if (A(x)>B(x)) std::swap(A,B);
	return A.k<=B.k?INF:(B(x)-A(x))/(A.k-B.k)+x+1; 
}
inline Node merge(reg Node A,reg Node B,reg int x){
	reg Node C={A.pre,B.suf,A.sum+B.sum,A.mn,min(A.t,B.t)};
	cmin(C.t,upd(C.suf,B.sum+A.suf,x)),cmin(C.t,upd(C.pre,A.sum+B.pre,x));
	cmin(C.t,upd(C.mn,B.mn,x)),cmin(C.t,upd(C.mn,A.suf+B.pre,x));
	return C;
}
void build(reg int &o,reg int l,reg int r){
	o=++idx; if (l==r) return tmp={-1,a[l]+b[l]},tmp2={-1,a[l]+b[l]+b[l-1]},tr[o]={tmp,tmp2,tmp,tmp2,INF},void();
	reg int mid=l+r>>1; build(ls[o],l,mid),build(rs[o],mid+1,r),tr[o]=merge(tr[ls[o]],tr[rs[o]],0);
}
void modify(reg int &o,reg int pre,reg int l,reg int r,reg int x){
	tr[o=++idx]=tr[pre],ls[o]=ls[pre],rs[o]=rs[pre]; if (l==r) return; reg int mid=l+r>>1;
	if (tr[ls[o]].t==x) modify(ls[o],ls[pre],l,mid,x); if (tr[rs[o]].t==x) modify(rs[o],rs[pre],l,mid,x); 
	tr[o]=merge(tr[ls[o]],tr[rs[o]],x);
}
Node query(reg int o,reg int l,reg int r,reg int L,reg int R,reg int x){
	if (L<=l&&r<=R) return tr[o]; reg int mid=l+r>>1;
	if (R<=mid) return query(ls[o],l,mid,L,R,x); if (L>mid) return query(rs[o],mid+1,r,L,R,x);
	return merge(query(ls[o],l,mid,L,R,x),query(rs[o],mid+1,r,L,R,x),x);
}
#undef int
std::vector<int> testset(std::vector<int> A, std::vector<int> B, std::vector<int> L, std::vector<int> U){
	std::vector<int> res;
	#define int long long
	n=A.size(); for (reg int i=1;i<=n;i++) a[i]=A[i-1],i<n?b[i]=B[i-1]:0;
	build(rt[m=1],1,n),lim[m]=0;
	while (1){
		if (tr[rt[m]].t>1000000000) break;
		lim[m+1]=tr[rt[m]].t,modify(rt[m+1],rt[m],1,n,lim[m+1]),m++;
	}
	lim[m+1]=1e9;
	// for (reg int i=1;i<=m;i++) std::cerr<<lim[i]<<" "; std::cerr<<"\n";
	// assert(0);
	for (reg int i=0;i<L.size();i++){
		// std::cerr<<"<< "<<i<<"\n";
		reg int l=1,r=m,now,pl=L[i]+1,pr=U[i]+1;
		while (l<=r){
			reg int mid=l+r>>1;
			if (query(rt[mid],1,n,pl,pr,lim[mid]).mn(lim[mid])>=0) l=mid+1,now=mid; else r=mid-1;
		}
		// std::cerr<<now<<"\n";
		// std::cerr<<"qwq\n";
		reg int ans; l=lim[now],r=lim[now+1]-1;
		while (l<=r){
			reg int mid=l+r>>1;
			if (query(rt[now],1,n,pl,pr,mid).mn(mid)>=0) l=mid+1,ans=mid; else r=mid-1;
		}
		res.push_back(ans);
	}
	return res;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 3
Accepted
time: 0ms
memory: 16400kb

input:

2 1
746 733
619
0 1

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
1049

result:

ok 2 lines

Test #2:

score: 3
Accepted
time: 0ms
memory: 16060kb

input:

3 1
620 302 785
59 605
0 2

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
679

result:

ok 2 lines

Test #3:

score: 0
Runtime Error

input:

100000 100000
85 25 780 928 387 223 750 400 72 245 24 189 172 110 18 2 18 53 578 143 175 117 40 143 2 308 297 201 531 265 10 117 68 13 763 171 288 107 338 815 16 767 533 57 343 63 936 886 2 220 832 302 203 431 8 158 886 16 43 471 103 441 3 349 228 29 84 110 396 36 276 139 13 321 71 36 5 34 59 730 69...

output:

Unauthorized output

result:


Subtask #2:

score: 0
Time Limit Exceeded

Test #11:

score: 0
Time Limit Exceeded

input:

100000 100
19808256 24285218 35700559 40271678 34848402 69357487 68150704 33167327 11009744 51263605 95965914 99915162 98938894 25021047 41422333 21862896 68096319 74258633 12048507 49456137 34627666 2028097 39447833 88604280 58491153 12515029 84711345 70929241 88589416 4246292 47068575 45272978 203...

output:

Unauthorized output

result:


Subtask #3:

score: 36
Accepted

Test #31:

score: 36
Accepted
time: 829ms
memory: 31220kb

input:

5000 100000
93608251 16211038 93349835 94727166 27749929 28580474 39398397 58978075 32539760 49630110 14330110 62149976 63372420 45530888 44815920 40624609 4942456 35245376 9509556 17318048 91459277 83937735 82541206 16905922 22994630 56339982 33531160 45581398 67402358 51369287 2786263 53237145 830...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
14700204
21288935
6977271
6977271
12647030
6977271
6977271
6977271
12647030
6977271
6977271
6977271
6977271
6977271
6977271
6977271
12647030
12647030
6977271
6977271
12647030
6977271
6977271
6977271
12647030
37448760
6977271
14700204
6977271
12647030
6977271
6977...

result:

ok 100001 lines

Test #32:

score: 36
Accepted
time: 802ms
memory: 31100kb

input:

5000 100000
82828123 95799582 43820359 90127238 56235887 78150460 93507009 96591806 86423481 94895084 82100076 94194957 91441292 90209583 97860572 97698652 68557340 99706593 34044897 93238691 86202199 88683188 86559347 93076047 73141247 97130836 89727854 98129702 85630933 80894303 73045164 85475297 ...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
126575860
126575860
126575860
143701045
126575860
170613823
143701045
143701045
126575860
126575860
172861749
126575860
126575860
126575860
126575860
126575860
143701045
143519126
126575860
143701045
133698077
126575860
152649240
126575860
152649240
152649240
126...

result:

ok 100001 lines

Test #33:

score: 36
Accepted
time: 682ms
memory: 27000kb

input:

5000 100000
96012616 99429813 99624750 99381014 99980502 99993037 99703586 99988048 99965210 99995994 99025192 84244649 97417197 99892788 99916470 99938573 96446673 99989453 85387315 99888398 99291260 99601349 91417592 99813237 99635623 92171538 96939941 99632513 99336374 98693179 98680317 99927733 ...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
190737948
191089420
190737948
190737948
190737948
193216637
192474531
198593332
190737948
190737948
190103821
190103821
190737948
190737948
190737948
192474531
191089420
190737948
191089420
190737948
190737948
190737948
190737948
190737948
190737948
190737948
190...

result:

ok 100001 lines

Test #34:

score: 36
Accepted
time: 662ms
memory: 32580kb

input:

5000 100000
99978725 97985760 99891087 99988604 99999807 98436639 99985292 99818187 99802110 99996115 99767504 99998401 99984142 99997383 99810342 99995097 98415433 99501601 99914594 98590782 99683661 99943693 99533008 99859805 99707573 99367915 99474753 99983916 99997167 98891838 99807634 99698506 ...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
198480881
198291296
198117670
198118365
198291296
198118365
198291296
198118365
198731701
198118365
198118365
198291296
198118365
198118365
198118365
198118365
198118365
198340225
198118365
199319379
198162408
198409770
198118365
198991009
198291296
198291296
198...

result:

ok 100001 lines

Test #35:

score: 36
Accepted
time: 608ms
memory: 31200kb

input:

5000 100000
99986950 99924484 99934484 99717257 99971564 99998421 99978242 99895349 96749877 99997733 99993399 99919842 99998954 99999449 99998116 99933290 99617595 99995807 99998100 99980424 99998867 99918225 99970258 99684050 99998452 99999220 99999506 99996872 99824516 99997016 99683701 99999926 ...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
199686196
199807313
199639454
199642418
199906533
199638768
199843110
199624132
199632837
199624132
199624132
199663148
199928583
199687670
199624132
200459148
199679834
199922294
199643504
199738578
199505764
199690967
199624132
199671888
199624132
199635012
199...

result:

ok 100001 lines

Test #36:

score: 36
Accepted
time: 590ms
memory: 32560kb

input:

5000 100000
99999716 99999957 99999766 99999362 99994650 99983426 99982710 99992590 99970275 99999417 99923465 99997667 99999313 99969772 99999965 99999765 99999932 99970260 99971602 99998087 99995083 99990390 99999965 99999903 99999983 99987568 99764871 99988931 99999921 99999997 99948237 99997572 ...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
200012937
199928913
199941598
199927017
199943363
200017855
200246008
199948078
199925951
199947905
199928097
199951853
199926393
199951747
200459076
199948116
199964966
199962331
200136933
199925034
200004530
199958929
199926718
200330875
199977900
199928348
199...

result:

ok 100001 lines

Test #37:

score: 36
Accepted
time: 547ms
memory: 26936kb

input:

5000 100000
99999533 99999866 100000000 99970378 99999161 99999464 99999996 99998365 99964169 99997634 99999993 99999473 100000000 99999941 99999972 99999401 99937711 99999481 99977698 99999786 99999937 99998392 99999993 99988404 99999902 99996253 99999751 99999452 99997119 99999997 99999992 9999930...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
200032680
199997335
200003854
200094192
200012569
200216900
200024050
200048503
200007926
200024448
200000731
200001613
200003651
200010947
199997617
200153052
200001803
200043401
199999942
200010043
200171395
200057532
200008012
200004766
200031196
200010272
200...

result:

ok 100001 lines

Test #38:

score: 36
Accepted
time: 547ms
memory: 26908kb

input:

5000 100000
99999758 100000000 99603367 100000000 99999999 100000000 99997096 99999979 99965697 99999966 99999223 99998539 100000000 99999877 99999998 99999824 99999844 99999997 99999233 99999899 100000000 99999991 99957113 99999944 99999962 99999740 99999980 99999868 99999997 99999974 99999881 9999...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
200019761
200150122
200041029
200122551
200297709
200015025
200842849
200027110
200015462
200023781
200330518
200147441
200024630
200078993
200033450
200016166
200026914
200017349
200046663
200019371
200017421
200047651
200028709
200037039
200014686
200038815
200...

result:

ok 100001 lines

Test #39:

score: 36
Accepted
time: 556ms
memory: 24880kb

input:

5000 100000
100000000 99999901 100000000 99999544 99998079 99998457 99999993 99999999 99999988 99999995 100000000 99999998 99990071 99998619 99999919 99999651 100000000 99999972 99999998 99999998 99999943 100000000 99999985 100000000 99999690 100000000 99998970 99999404 100000000 100000000 99997512 ...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
200334858
200024712
200019014
200065522
200069977
200046162
224998883
200033514
201189765
200021347
200026764
200039384
200065482
200047927
200132766
200046145
200034834
200129514
200088211
200052188
200028371
200914980
200090338
200034837
200024336
200074799
200...

result:

ok 100001 lines

Test #40:

score: 36
Accepted
time: 562ms
memory: 28212kb

input:

5000 100000
99999997 99972589 99999989 99999998 100000000 100000000 100000000 99999999 99999997 100000000 100000000 99999986 100000000 100000000 100000000 100000000 100000000 100000000 99999259 99999908 99999912 99999966 99999861 100000000 99999910 99999938 100000000 99999975 99999998 100000000 9999...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
200102904
200023462
200030554
200029853
200035517
200097747
200052047
200032106
200096592
200077847
200031232
200031513
202380483
200026141
200025215
200028172
200419991
200068586
200028405
200036541
200022617
200072713
200118037
200047356
200082748
200042939
200...

result:

ok 100001 lines

Test #41:

score: 36
Accepted
time: 484ms
memory: 26800kb

input:

5000 100000
100000000 34490431 34500526 34510574 34520605 34530624 34540623 34550606 34560573 34570531 34580483 34590430 34600376 34610320 34620262 34630201 34640138 34650072 34660004 34669936 34679865 34689789 34699708 34709624 34719539 34729449 34739356 34749262 34759167 34769072 34778975 34788874...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
99117098
99020632
99019531
99034786
99026379
99021290
99089284
99036804
99023789
99020470
99270639
99109623
99019388
99031205
99020786
99083581
99052312
99025409
99024581
99023703
99025787
99296577
99022511
99018632
99019939
99021042
99020623
99041599
99028376
99...

result:

ok 100001 lines

Test #42:

score: 36
Accepted
time: 452ms
memory: 26792kb

input:

5000 100000
100000000 63746319 63756413 63766483 63776550 63786599 63796640 63806670 63816697 63826722 63836744 63846760 63856767 63866766 63876761 63886729 63896682 63906631 63916571 63926510 63936448 63946380 63956295 63966210 63976124 63986031 63995933 64005832 64015728 64025617 64035497 64045374...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
99045423
99015355
99014713
99203257
99016588
99090518
99019463
99017344
99033260
99029813
99151503
99014785
99015880
99019194
99014905
99042875
99026871
99016538
99016863
99021238
99031573
99014618
99020248
99014986
99022724
99014978
99017384
99019945
99033071
99...

result:

ok 100001 lines

Test #43:

score: 36
Accepted
time: 482ms
memory: 26872kb

input:

5000 100000
100000000 40082058 40102071 40122065 40142048 40162022 40181974 40201922 40221868 40241807 40261723 40281621 40301509 40321386 40341258 40361119 40380975 40400824 40420669 40440507 40460340 40480163 40499981 40519787 40539590 40559382 40579169 40598944 40618712 40638472 40658225 40677974...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
99024128
99022762
99031040
99049415
99026395
99022715
99023798
99024489
99055741
99023890
99027801
99031139
99023003
99030425
99035240
99026628
99030935
99031906
99022761
99024415
99077964
99030756
99027615
99023150
99034631
99031133
99067501
99030131
99028727
99...

result:

ok 100001 lines

Test #44:

score: 36
Accepted
time: 434ms
memory: 32336kb

input:

5000 100000
100000000 54900931 54921022 54941078 54961120 54981139 55001127 55021106 55041076 55061005 55080930 55100849 55120767 55140672 55160564 55180425 55200282 55220129 55239972 55259796 55279611 55299415 55319212 55339003 55358787 55378561 55398322 55418083 55437843 55457600 55477355 55497109...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
99022059
99056614
99021410
99021145
99022437
99021145
99022012
99053074
99021657
99035443
99021256
99025053
99081374
99023212
99021728
99032240
99027767
99036278
99021717
99041735
99021522
99045989
99044987
99210799
99021146
99021145
99021556
99021269
99026498
99...

result:

ok 100001 lines

Test #45:

score: 36
Accepted
time: 452ms
memory: 26900kb

input:

5000 100000
100000000 40640921 40670926 40700905 40730875 40760834 40790786 40820704 40850611 40880509 40910391 40940265 40970120 40999959 41029779 41059593 41089395 41119191 41148974 41178743 41208499 41238250 41267992 41297701 41327394 41357060 41386719 41416377 41446030 41475679 41505305 41534923...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
99069952
99026839
99027439
99033653
99053605
99060673
99071644
99118736
99026794
99026794
99124005
99032123
99027126
99039913
99030478
99030857
99029123
99027317
99026821
99027744
99026833
99029923
99027824
99026923
99030128
99026794
99026794
99031897
99097361
99...

result:

ok 100001 lines

Test #46:

score: 36
Accepted
time: 454ms
memory: 33076kb

input:

5000 100000
100000000 41022674 41052707 41082678 41112642 41142602 41172553 41202486 41232385 41262275 41292151 41322014 41351863 41381707 41411545 41441378 41471196 41501012 41530819 41560621 41590390 41620157 41649913 41679640 41709357 41739066 41768743 41798411 41828071 41857726 41887367 41917006...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
99028492
99028492
99030502
99030106
99266486
99080075
99030419
99032835
99028492
99028714
99028518
99035564
99038776
99028862
99032121
99031353
99242152
99074511
99028835
99081583
99029058
99032337
99028492
99236456
99148891
99028878
99102174
99266463
99030264
99...

result:

ok 100001 lines

Test #47:

score: 36
Accepted
time: 443ms
memory: 32776kb

input:

5000 100000
100000000 41199794 41239810 41279783 41319711 41359633 41399526 41439411 41479267 41519105 41558934 41598754 41638555 41678345 41718120 41757886 41797643 41837382 41877094 41916785 41956446 41996093 42035732 42075356 42114965 42154566 42194143 42233708 42273259 42312803 42352328 42391844...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
99028547
99028528
99030712
99028528
99028528
99031045
99028528
99028528
99028528
99028528
99041049
99154301
99028528
99032626
99028528
99028607
99028545
99028528
99029287
99028528
99029112
99040780
99031452
99042631
99075758
99028593
99028528
99028528
99028528
99...

result:

ok 100001 lines

Test #48:

score: 36
Accepted
time: 433ms
memory: 32372kb

input:

5000 100000
100000000 47816681 47856717 47896677 47936628 47976566 48016499 48056400 48096251 48136097 48175900 48215688 48255453 48295214 48334966 48374707 48414444 48454141 48493829 48533502 48573170 48612828 48652465 48692098 48731713 48771320 48810917 48850503 48890069 48929634 48969191 49008716...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
99025572
99029621
99026252
99049460
99025572
99025572
99025572
99037725
99025572
99025572
99035194
99027480
99226501
99064901
99025572
99025572
99065398
99035806
99025681
99025572
99025608
99077539
99054897
99025572
99244538
99025572
99031732
99061316
99031290
99...

result:

ok 100001 lines

Test #49:

score: 36
Accepted
time: 436ms
memory: 27112kb

input:

5000 100000
100000000 33286406 33336419 33386369 33436277 33486170 33536029 33585880 33635713 33685529 33735329 33785122 33834900 33884676 33934405 33984103 34033783 34083438 34133075 34182693 34232287 34281841 34331393 34380940 34430478 34479995 34529486 34578966 34628417 34677831 34727236 34776606...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
99031342
99031342
99065680
99043925
99031342
99031342
99031342
99034359
99059108
99031342
99031342
99031342
99031342
99031342
99043608
99048202
99031342
99065661
99031342
99032653
99040965
99031877
99031342
99031342
99031342
99031745
99031342
99031405
99032076
99...

result:

ok 100001 lines

Test #50:

score: 36
Accepted
time: 418ms
memory: 32688kb

input:

5000 100000
100000000 34657949 34707964 34757908 34807830 34857744 34907639 34957510 35007352 35057186 35106998 35156805 35206599 35256348 35306093 35355790 35405479 35455158 35504801 35554424 35604018 35653602 35703181 35752715 35802234 35851737 35901232 35950684 36000119 36049545 36098959 36148353...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
99110202
99032176
99047827
99125141
99049462
99031795
99031795
99031795
99046190
99035590
99031795
99060172
99032975
99031795
99036639
99031795
99031795
99031807
99031795
99031795
99032545
99031795
99055011
99035829
99031795
99045662
99031946
99316138
99031795
99...

result:

ok 100001 lines

Subtask #4:

score: 0
Time Limit Exceeded

Test #51:

score: 0
Time Limit Exceeded

input:

100000 100000
8220608 27643636 9653375 7527483 4568995 4937547 27001430 10512886 14865249 54452685 31213146 1223559 25266797 9367382 5798933 1485258 33036920 2988776 5046089 41823731 6136379 20608943 10327625 90179994 75745370 21933251 3376845 19790905 52189711 21570452 18938610 18445540 26257950 24...

output:

Unauthorized output

result:


Subtask #5:

score: 0
Skipped

Dependency #1:

0%