QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#608561#6665. 팀 만들기Matutino35 1498ms34400kbC++172.8kb2024-10-03 23:12:152024-10-03 23:12:15

Judging History

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

  • [2024-10-03 23:12:15]
  • 评测
  • 测评结果:35
  • 用时:1498ms
  • 内存:34400kb
  • [2024-10-03 23:12:15]
  • 提交

answer

#include<bits/stdc++.h>
#define reg register
#define int long long
inline bool cmax(reg int &x,reg int y){return x<y?x=y,1:0;}
inline int max(reg int x,reg int y){return x>y?x:y;}
const int N=1e5+10,B=300;
int n,m,q,now_max,A[N],bel1[N],bel2[N];
std::pair<int,int> p1[N],p2[N];
int p1L[N],p1R[N],p2L[N],p2R[N],st[20][N];
inline int cost(reg std::pair<int,int> A,reg std::pair<int,int> B){auto [a,b]=A; auto [c,d]=B; return (a+c)*(b+d);}
void dc(reg int l,reg int r,reg int L,reg int R){
	if (l>r||L>R) return; reg int mid=l+r>>1,p=L,mx=cost(p2[L],p1[mid]);
	for (reg int i=L;i<=R;i++) if (cmax(mx,cost(p2[i],p1[mid]))) p=i;
	cmax(now_max,mx),st[0][mid]=mx; dc(l,mid-1,p,R),dc(mid+1,r,L,p);
}
inline int query(reg int l,reg int r){reg int L=std::__lg(r-l+1); return max(st[L][l],st[L][r-(1<<L)+1]);}
#undef int 
std::vector<long long> build_teams(std::vector<int> A1, std::vector<int> B1, std::vector<int> A2, std::vector<int> B2, std::vector<int> L1, std::vector<int> R1, std::vector<int> L2, std::vector<int> R2) {
	#define int long long
	n=A1.size(),m=A2.size(),q=L1.size();
	std::vector<int> ans(q);
	for (reg int i=0;i<=q;i++) L1[i]++,R1[i]++,L2[i]++,R2[i]++;
	for (reg int i=1;i<=n;i++) bel1[i]=(i-1)/B+1,p1R[bel1[i]]=i;
	for (reg int i=n;i;i--) p1L[bel1[i]]=i;
	for (reg int i=1;i<=m;i++) bel2[i]=(i-1)/B+1,p2R[bel2[i]]=i;
	for (reg int i=m;i;i--) p2L[bel2[i]]=i;
	for (reg int i=0;i<q;i++){
		reg int m1=0,m2=0;
		if (bel1[L1[i]]==bel1[R1[i]]) for (reg int j=L1[i];j<=R1[i];j++) p1[++m1]={A1[j-1],B1[j-1]};
		else{
			for (reg int j=L1[i];j<=p1R[bel1[L1[i]]];j++) p1[++m1]={A1[j-1],B1[j-1]};
			for (reg int j=R1[i];j>=p1L[bel1[R1[i]]];j--) p1[++m1]={A1[j-1],B1[j-1]};
		}
		if (bel2[L2[i]]==bel2[R2[i]]) for (reg int j=L2[i];j<=R2[i];j++) p2[++m2]={A2[j-1],B2[j-1]};
		else{
			for (reg int j=L2[i];j<=p2R[bel2[L2[i]]];j++) p2[++m2]={A2[j-1],B2[j-1]};
			for (reg int j=R2[i];j>=p2L[bel2[R2[i]]];j--) p2[++m2]={A2[j-1],B2[j-1]};
		}
		now_max=0,dc(1,m1,1,m2),cmax(ans[i],now_max);
	}
	for (reg int i=1;i<=m;i++) p1[i]={A2[i-1],B2[i-1]};
	for (reg int i=1;i<=bel1[n];i++){
		reg int l=p1L[i],r=p1R[i];
		for (reg int j=l;j<=r;j++) p2[j-l+1]={A1[j-1],B1[j-1]};
		dc(1,m,1,r-l+1);
		for (reg int j=1;1<<j<=m;j++) for (reg int x=1;x+(1<<j)<=m;x++) 
			st[j][x]=max(st[j-1][x],st[j-1][x+(1<<j-1)]);
		for (reg int j=0;j<q;j++) if (L1[j]<=l&&r<=R1[j]) cmax(ans[j],query(L2[j],R2[j]));
	}
	for (reg int i=1;i<=n;i++) p1[i]={A1[i-1],B1[i-1]};
	for (reg int i=1;i<=bel2[m];i++){
		reg int l=p2L[i],r=p2R[i];
		for (reg int j=l;j<=r;j++) p2[j-l+1]={A2[j-1],B2[j-1]};
		dc(1,n,1,r-l+1);
		for (reg int j=1;1<<j<=n;j++) for (reg int x=1;x+(1<<j)<=n;x++) 
			st[j][x]=max(st[j-1][x],st[j-1][x+(1<<j-1)]);
		for (reg int j=0;j<q;j++) if (L2[j]<=l&&r<=R2[j]) cmax(ans[j],query(L1[j],R1[j]));
	}
	return ans;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 5
Accepted
time: 0ms
memory: 20432kb

input:

500 499
7 4997
13 4988
20 4983
28 4969
44 4963
49 4922
54 4919
58 4897
71 4893
72 4886
85 4883
102 4879
107 4876
113 4868
128 4845
133 4839
135 4831
138 4821
140 4809
156 4793
178 4780
181 4776
190 4760
196 4756
203 4752
209 4736
225 4728
228 4723
232 4720
235 4709
253 4676
258 4660
260 4645
266 463...

output:

25745327
24221652
25260576
25444230
25944610
26027379
25944610
21794500
25502475
19748843
25944610
25269202
25294500
24084151
25944610
25944610
25923420
25745327
24097815
21842574

result:

ok 20 lines

Test #2:

score: 5
Accepted
time: 0ms
memory: 14064kb

input:

500 499
3 4994
6 4989
12 4978
20 4972
22 4965
32 4949
48 4914
52 4893
56 4875
62 4867
66 4860
80 4840
98 4828
106 4814
108 4788
127 4785
142 4783
177 4775
181 4770
182 4766
191 4764
201 4757
205 4753
235 4743
298 4740
300 4725
326 4720
346 4714
350 4709
373 4703
379 4680
390 4674
391 4643
393 4640
3...

output:

22404249
24625440
24983847
24994621
26178282
25385964
25028495
18972628
24778368
24808000
25212965
24604640
23302608
24979302
22241460
25385964
24155109
26178282
25137864
25619090

result:

ok 20 lines

Test #3:

score: 0
Wrong Answer
time: 1ms
memory: 3916kb

input:

500 499
3 4988
4 4967
8 4953
10 4942
11 4936
13 4930
20 4927
40 4904
43 4897
61 4892
65 4852
70 4849
74 4815
78 4812
90 4801
91 4792
107 4783
116 4781
121 4770
123 4747
125 4738
129 4706
132 4700
134 4698
139 4684
145 4680
148 4667
155 4665
164 4652
181 4651
188 4649
191 4648
199 4646
202 4628
209 4...

output:

25458244
17507070
23722057
23685867
24493896
26156980
21925946
26222616
25564880
25172184
24611064
17491437
25418853
25931580
25654056
25144644
26156980
25931580
17224980
25581918

result:

wrong answer 15th lines differ - expected: '25669456', found: '25654056'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #47:

score: 0
Wrong Answer
time: 616ms
memory: 24340kb

input:

200 100000
335635 996427627
4368692 990235584
10335314 971208588
11639195 971143844
23801483 970115479
31489602 959110431
31544396 956821351
48348198 954187112
48509739 953684848
51173262 952420589
53207608 941523603
62582103 940608015
65545228 932323862
73708623 932037283
80559453 929148992
9033280...

output:

993958698780308505
1059275121529352398
1059275121529352398
1059275121529352398
979409542016948625
1059275121529352398
1059275121529352398
1059275121529352398
1059275121529352398
972560707248716820
1011171607306697480
1043073690916288143
1059275121529352398
1059275121529352398
1059275121529352398
976...

result:

wrong answer 95th lines differ - expected: '1014112203229699875', found: '1013748732533769888'

Subtask #4:

score: 35
Accepted

Test #65:

score: 35
Accepted
time: 165ms
memory: 31268kb

input:

200 100000
2904660 993940483
16886371 993289642
17317405 990982034
18403947 976774733
18849359 973351068
19183185 970254940
19306003 966229683
21192298 964806508
23734314 964320708
23888967 955733824
27113148 951453312
37031360 944529530
39266197 937051115
40090929 928931574
59651306 922916360
69712...

output:

1016308928382908236
998776313884663776
1004320593689684616
933903565326321240
978390546778315197
1039650121469876757
987990669763090785
1042865155786780773
1051441808434023804
971637196420999780
1065416677472286269
1012697889755804003
905550355710151258
1060082943529963956
1013827359119034944
104933...

result:

ok 100000 lines

Test #66:

score: 35
Accepted
time: 359ms
memory: 32488kb

input:

100000 200
1940 999994594
10389 999989035
28503 999981667
30870 999980471
42230 999972276
52125 999971275
53379 999956174
55518 999955459
64639 999955412
65268 999904054
67682 999885452
77130 999857307
93130 999831628
108438 999823346
126919 999823214
134181 999822103
143172 999812542
147613 9998090...

output:

996157338533370640
969910467114454830
919033115031420852
1007516186713478702
962916440953422100
962471973287936504
972319486384869810
934783008648683200
951496772109547560
706137145445760420
1007389400623713408
922982135677214509
949242387888579640
994933150384658286
956985211239863942
8954485248407...

result:

ok 100000 lines

Test #67:

score: 35
Accepted
time: 954ms
memory: 32384kb

input:

83655 67941
7 1999962
11 1999959
52 1999912
114 1999905
141 1999893
148 1999886
166 1999882
190 1999863
255 1999839
285 1999833
334 1999812
355 1999799
364 1999781
380 1999767
383 1999754
386 1999730
408 1999605
412 1999562
422 1999560
440 1999542
450 1999503
459 1999492
475 1999455
480 1999427
501 ...

output:

3999222907200
4001983880076
3990553194405
3984364771144
3993622565344
3979750168368
3970350645352
3977481088735
4000283761242
4003533367722
3964048832904
3983619288906
3968751744960
3989628017544
3993891796440
3999919280896
3977177641920
3975851409101
3970293405862
3999692385936
3970269025863
398116...

result:

ok 100000 lines

Test #68:

score: 35
Accepted
time: 1252ms
memory: 33432kb

input:

83655 100000
2744 999958137
5472 999951851
26111 999947393
38192 999946937
58183 999894788
68110 999893744
79945 999882940
83120 999879883
90133 999874493
96315 999861970
118429 999861459
121710 999860574
123096 999860348
128209 999857742
142703 999856987
149105 999852071
170573 999833691
191854 999...

output:

983924467131171374
1000094487222197304
962556865281586408
998619076099805400
974602612077840540
999508325895969694
984190464018162586
546226782131837140
966044532732941088
996631173521174944
1000485293063806440
1000429350728955099
976028077060336554
963738447278590916
998457316618862640
641775578224...

result:

ok 100000 lines

Test #69:

score: 35
Accepted
time: 1041ms
memory: 33060kb

input:

91626 67941
17 1999958
68 1999937
112 1999919
116 1999913
131 1999906
148 1999871
184 1999840
190 1999832
236 1999816
242 1999795
262 1999758
294 1999755
318 1999753
349 1999746
364 1999714
420 1999698
492 1999697
493 1999678
579 1999565
582 1999529
603 1999513
611 1999490
620 1999416
640 1999407
66...

output:

4011919825620
4001294172906
3964878372962
4017434856827
4008507902740
4008312506900
4001256029952
4001894004672
4009195628158
4021016366089
4000770309822
4011465875937
4021945456923
4000697833850
4017353967220
4019056127198
4007233081082
3925623205440
4006707591072
3997721673061
4005828702960
400325...

result:

ok 100000 lines

Test #70:

score: 35
Accepted
time: 1374ms
memory: 33568kb

input:

100000 98765
17 1999942
40 1999911
50 1999868
57 1999849
116 1999847
132 1999843
133 1999811
145 1999777
216 1999773
228 1999765
231 1999754
344 1999736
384 1999728
395 1999715
443 1999713
446 1999710
525 1999706
526 1999684
559 1999662
573 1999651
610 1999641
613 1999616
615 1999614
618 1999613
645...

output:

4001728269760
3004157173204
3999871214640
3996456603782
1645288748784
4007523592317
3892631840586
3350605144002
3942260877940
4002077716268
4002239149902
3721895839536
3994066622592
2259164158392
3908362692048
4008552682820
2164282382796
4004692146375
4004336956025
3971477175429
4002058531104
402046...

result:

ok 100000 lines

Test #71:

score: 35
Accepted
time: 1394ms
memory: 34360kb

input:

100000 100000
4162 999990442
10078 999953844
35182 999949615
36566 999921246
39144 999905128
41451 999894903
62296 999886097
66032 999876871
71400 999852131
72429 999836760
72607 999823527
73724 999818025
83996 999795621
96017 999775325
103111 999768841
111921 999764163
116304 999763402
119468 99975...

output:

945709894092043080
919435268123238809
998446187867165815
1001947154674498626
1000177067408407812
1002326745726847246
903614354345641050
936434101846321770
999894397668913922
926088059227658012
749603264343542400
995900139199788292
1002901875888448800
999400791146328225
999539890246704412
88173530970...

result:

ok 100000 lines

Test #72:

score: 35
Accepted
time: 1485ms
memory: 34400kb

input:

100000 100000
3 2000000
23 1999986
59 1999937
70 1999908
75 1999904
117 1999838
124 1999826
130 1999811
141 1999787
147 1999746
188 1999735
193 1999731
197 1999724
232 1999690
258 1999667
272 1999658
278 1999648
283 1999639
286 1999611
300 1999578
304 1999556
349 1999535
356 1999525
380 1999520
381 ...

output:

3943543720635
3982077966375
3981345522315
3997980258968
4010814112464
4000937430880
3994782297417
3980769105375
3999328369326
4000122509700
3974210352936
3567937385466
3996055495160
4003016470760
3994109612328
4011047218176
3988095683915
3996114235406
3987640308000
4008705284285
3969876302582
332324...

result:

ok 100000 lines

Test #73:

score: 35
Accepted
time: 1498ms
memory: 33844kb

input:

100000 100000
1 1499986
15 1499971
29 1499956
43 1499941
57 1499926
71 1499911
85 1499896
99 1499881
113 1499866
127 1499851
141 1499836
155 1499821
169 1499806
183 1499791
197 1499776
211 1499761
225 1499746
239 1499731
253 1499716
267 1499701
281 1499686
295 1499671
309 1499656
323 1499641
337 149...

output:

2099963800156
2099963800156
2099963800156
2099963800156
2099963800156
2099963800156
2099963800156
2099963800156
2099963800156
2099963800156
2099963800156
2099963800156
2099963800156
2099963800156
2099963800156
943031491644
2099963800156
2099963800156
2099963800156
1123231907548
2099963800156
2099963...

result:

ok 100000 lines

Test #74:

score: 35
Accepted
time: 1488ms
memory: 31540kb

input:

100000 100000
1 1499986
30 1499971
59 1499956
88 1499941
117 1499926
146 1499911
175 1499896
204 1499881
233 1499866
262 1499851
291 1499836
320 1499821
349 1499806
378 1499791
407 1499776
436 1499761
465 1499746
494 1499731
523 1499716
552 1499701
581 1499686
610 1499671
639 1499656
668 1499641
697...

output:

4332187443696
3928616190128
4216520778047
3776127471248
3794432053056
4091895261416
3813967895744
3449285152667
4085926907696
4348160801375
4235012651520
4104720549787
3977243808411
4349921800351
4268193579832
4249260223775
4120127492543
4349921800351
4324716580575
4349921800351
4167541413119
434992...

result:

ok 100000 lines

Test #75:

score: 35
Accepted
time: 1449ms
memory: 33852kb

input:

100000 100000
1 4299958
43 4299915
85 4299872
127 4299829
169 4299786
211 4299743
253 4299700
295 4299657
337 4299614
379 4299571
421 4299528
463 4299485
505 4299442
547 4299399
589 4299356
631 4299313
673 4299270
715 4299227
757 4299184
799 4299141
841 4299098
883 4299055
925 4299012
967 4298969
10...

output:

18059655801640
18059655801640
14997798475240
18058097147736
18059655801640
18059655801640
18059655801640
18059655801640
18059655801640
18059655801640
18059655801640
18059655801640
18059655801640
18059655801640
18059655801640
18059655801640
18059655801640
18059655801640
18059655801640
18059655801640
...

result:

ok 100000 lines

Test #76:

score: 35
Accepted
time: 1403ms
memory: 32016kb

input:

100000 100000
1 543194569
1235 543189137
2469 543183705
3703 543178273
4937 543172841
6171 543167409
7405 543161977
8639 543156545
9873 543151113
11107 543145681
12341 543140249
13575 543134817
14809 543129385
16043 543123953
17277 543118521
18511 543113089
19745 543107657
20979 543102225
22213 5430...

output:

31694305396352980
67029540722289760
46892552540197720
49750347821772880
66543303556174060
67029540722289760
67029540722289760
60089004921320056
67029540722289760
55456756156916068
49618047822614568
66993368634621900
65598556763944468
67029540722289760
63195220758501396
67029540722289760
668796366489...

result:

ok 100000 lines

Test #77:

score: 35
Accepted
time: 1484ms
memory: 34372kb

input:

100000 100000
1 123398767
5433 123397533
10865 123396299
16297 123395065
21729 123393831
27161 123392597
32593 123391363
38025 123390129
43457 123388895
48889 123387661
54321 123386427
59753 123385193
65185 123383959
70617 123382725
76049 123381491
81481 123380257
86913 123379023
92345 123377789
977...

output:

67029540722289760
57170643925662076
59247917640565056
62696459143551460
65436324827581660
66794065688858716
67029540722289760
57067030921105216
66413456009660236
52813103814888556
65837940327604396
57476715606400068
62392023755115580
67029540722289760
67029540722289760
67029540722289760
670295407222...

result:

ok 100000 lines

Test #78:

score: 35
Accepted
time: 1382ms
memory: 33848kb

input:

100000 100000
2011 439611441
9819 439602235
12251 439597274
14412 439594648
22454 439589669
27321 439586063
36882 439576574
41078 439571160
48382 439563367
54747 439557385
62466 439555018
68177 439545707
74920 439543759
76675 439538403
77355 439529163
81603 439519750
86515 439510104
87490 439509606
...

output:

184495651787973988
181923629414795060
174191819705369520
156559517280177440
188163564167420644
208821606541187600
208574976963218814
186924179541744366
182722169646833756
186778086203271124
202318663166065395
208811819127046119
179967603904841865
164425677085464220
189205284988814347
131016833293158...

result:

ok 100000 lines

Test #79:

score: 35
Accepted
time: 1377ms
memory: 31760kb

input:

100000 100000
1662 307365647
6858 307363904
12229 307362357
18693 307358535
19263 307353644
26363 307349898
28864 307343564
38858 307341119
43334 307340389
47884 307337268
57019 307334878
60444 307331401
70215 307328031
73360 307320414
81715 307314209
87273 307307290
92252 307303024
94195 307297517
...

output:

99008644183118800
93659573411886419
95056264538369225
97058244783565110
63491657537138223
97172672594929546
104705689314887375
82253041043727008
104842856410367820
63574123954375732
98689757613368769
91225920823333524
98436284154367131
80872246618988544
89959457952269725
101238902174218368
998486969...

result:

ok 100000 lines

Test #80:

score: 35
Accepted
time: 1432ms
memory: 33764kb

input:

100000 100000
5287 162137536
6725 162135907
9983 162133314
18267 162133268
26084 162130692
33269 162129105
36867 162126180
43454 162125830
45833 162125320
48324 162124911
57558 162124298
57746 162122753
67096 162119868
68667 162119132
75820 162117933
78531 162117228
82394 162114547
84733 162111893
8...

output:

110684473714716132
86989046243985093
73863963014354520
115887519803433734
60341204407168320
107684609098476886
106022266068565728
110028525616500904
50094793291128201
41375610080618850
62136938682377802
118420997665582722
68542758602020299
90180058985637768
80752950656281728
70950332567807472
416454...

result:

ok 100000 lines

Test #81:

score: 35
Accepted
time: 1367ms
memory: 34076kb

input:

100000 100000
205 7833516
677 7833225
970 7833222
1497 7832812
1540 7832400
1767 7832185
2215 7831940
2366 7831722
2458 7831608
2738 7831135
2838 7830972
3100 7830781
3294 7830615
3537 7830523
3958 7830013
4442 7829640
4973 7829549
5227 7829158
5753 7829089
6141 7828931
6511 7828758
6914 7828704
703...

output:

42951073529650
106288606017620
163258603593432
164961511164726
164495932098531
131262741249926
121257283855860
148303142782340
114574440538392
181578771085038
168958722274359
145186185721600
103243832760677
90272441086675
138806259562475
162527994392120
120633708038328
162737535948624
13811321690714...

result:

ok 100000 lines

Subtask #5:

score: 0
Skipped

Dependency #1:

0%