QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#516716#6815. Hysteretic Racingyjf1225AC ✓1194ms32768kbC++145.0kb2024-08-12 20:47:112024-08-12 20:47:11

Judging History

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

  • [2024-08-12 20:47:11]
  • 评测
  • 测评结果:AC
  • 用时:1194ms
  • 内存:32768kb
  • [2024-08-12 20:47:11]
  • 提交

answer

#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
namespace Y{
	const long long N=2e5+10;
	
	long long d[N];
	struct Node{
		long long maxx,sum_max,sum_d,ans;
		long long flag,flag2;
	}tree[4*N];
	long long Sum,maxx,ans;
	
	void down_(long long k,long long d,long long l,long long r){
		if(d!=0){ //要区间赋值!!! 
			tree[k].ans=d*d*(r-l+1);
			tree[k].sum_max=(r-l+1)*d;
			tree[k].sum_d=(r-l+1)*d;
			tree[k].maxx=d;
			
			tree[k].flag=d;
			tree[k].flag2=0;
		}
	}
	
	void down_2(long long k,long long d,long long l,long long r){
		tree[k].ans+=(tree[k].sum_max+tree[k].sum_d)*d+d*d*(r-l+1);
		tree[k].sum_max+=(r-l+1)*d;
		tree[k].sum_d+=(r-l+1)*d;
		tree[k].maxx+=d;
		
		tree[k].flag2+=d;
	}
	
	void down(long long k,long long l,long long mid,long long r){
		down_(2*k,tree[k].flag,l,mid);
		down_(2*k+1,tree[k].flag,mid+1,r);
		tree[k].flag=0;
		down_2(2*k,tree[k].flag2,l,mid);
		down_2(2*k+1,tree[k].flag2,mid+1,r);
		tree[k].flag2=0;
	}
	
	long long find_sum_maxx(long long k,long long maxx,long long l,long long r){
		if(l==r) return max(maxx,tree[k].maxx);
		long long mid=(l+r)>>1;
		down(k,l,mid,r);
		if(tree[2*k].maxx<=maxx){
			return (mid-l+1)*maxx+find_sum_maxx(2*k+1,maxx,mid+1,r);
		}
		else{
			return find_sum_maxx(2*k,maxx,l,mid)+tree[k].sum_max-tree[2*k].sum_max;
		}
	}
	
	long long find_ans(long long k,long long maxx,long long l,long long r){
		if(l==r) return max(tree[k].maxx,maxx)*tree[k].sum_d;
		long long mid=(l+r)>>1;
		down(k,l,mid,r);
		if(tree[2*k].maxx<=maxx){
			return tree[2*k].sum_d*maxx+find_ans(2*k+1,maxx,mid+1,r);
		}
		else{
			return find_ans(2*k,maxx,l,mid)+tree[k].ans-tree[2*k].ans;
		}
	}
	
	void up(long long k,long long l,long long mid,long long r){
		tree[k].maxx=max(tree[2*k].maxx,tree[2*k+1].maxx);
		tree[k].sum_d=tree[2*k].sum_d+tree[2*k+1].sum_d;
		tree[k].ans=tree[2*k].ans+find_ans(2*k+1,tree[2*k].maxx,mid+1,r);
		tree[k].sum_max=tree[2*k].sum_max+find_sum_maxx(2*k+1,tree[2*k].maxx,mid+1,r);
	}
	
	void build(long long k,long long l,long long r){
		if(l==r){
			tree[k].sum_max=tree[k].sum_d=tree[k].maxx=d[l];
			tree[k].ans=d[l]*d[l];
			return ;
		}
		long long mid=(l+r)>>1;
		down(k,l,mid,r);
		build(2*k,l,mid);
		build(2*k+1,mid+1,r);
		up(k,l,mid,r);
	}
	
	void dd(long long k,long long l,long long r){
		if(l==r){
			return ;
		}
		long long mid=(l+r)>>1;
		down(k,l,mid,r);
		dd(2*k,l,mid);
		dd(2*k+1,mid+1,r);
		up(k,l,mid,r);
	}
	
	void modify1(long long k,long long l,long long r,long long L,long long R,long long d){
		if(r<L || R<l) return ;
		if(L<=l && r<=R){
			down_2(k,d,l,r);
			return ;
		}
		long long mid=(l+r)>>1;
		down(k,l,mid,r);
		modify1(2*k,l,mid,L,R,d);
		modify1(2*k+1,mid+1,r,L,R,d);
		up(k,l,mid,r);
	}
	
	void modify2(long long k,long long l,long long r,long long L,long long R,long long d){
		if(r<L || R<l) return ;
		if(L<=l && r<=R){
			down_(k,d,l,r);
			return ;
		}
		long long mid=(l+r)>>1;
		down(k,l,mid,r);
		modify2(2*k,l,mid,L,R,d);
		modify2(2*k+1,mid+1,r,L,R,d);
		up(k,l,mid,r);
	}
	
	void query2(long long k,long long l,long long r){
		long long tmp=find_ans(k,maxx,l,r);
		if(Sum-tmp>=0){
			Sum-=tmp;
			maxx=max(maxx,tree[k].maxx);
			return ;
		}
		if(l==r){
			Sum-=tmp;
			ans=l;
			return ;
		}
		long long mid=(l+r)>>1;
		down(k,l,mid,r);
		query2(2*k,l,mid);
		if(Sum<0) return ;
		query2(2*k+1,mid+1,r);
//		up(k,l,mid,r);
	}
	
	void query(long long k,long long l,long long r,long long L,long long R){
		if(r<L || R<l) return ;
		if(L<=l && r<=R){
			query2(k,l,r);
			return ;
		}
		long long mid=(l+r)>>1;
		down(k,l,mid,r);
		query(2*k,l,mid,L,R);
		if(Sum<0) return ;
		query(2*k+1,mid+1,r,L,R);
//		up(k,l,mid,r);
	}
	
	signed main(){
		long long n,t;
		cin>>n>>t;
		
		for(long long i=0;i<n;i++){
			scanf("%lld",&d[i]);
		}
		
		build(1,0,n-1);
		
		char op[2];long long x,y,z;
		while(t--){
			scanf("%s",op);
			if(op[0]=='P'){
				scanf("%lld%lld%lld",&x,&y,&z);
//				for(int i=x;;i=(i+1)%n){
//					d[i]+=z;
//					if(i==y) break;
//				}
				if(x<=y) modify1(1,0,n-1,x,y,z);
				else modify1(1,0,n-1,x,n-1,z),modify1(1,0,n-1,0,y,z);
//				dd(1,0,n-1);
			}
			else if(op[0]=='R'){
				scanf("%lld%lld%lld",&x,&y,&z);
//				for(int i=x;;i=(i+1)%n){
//					d[i]=z;
//					if(i==y) break;
//				}
				if(x<=y) modify2(1,0,n-1,x,y,z);
				else modify2(1,0,n-1,x,n-1,z),modify2(1,0,n-1,0,y,z);
//				dd(1,0,n-1);
			}
			else{
				scanf("%lld%lld",&x,&y);
				Sum=y;maxx=0;
				query(1,0,n-1,x,n-1);
//				cout<<"???"<<Sum<<' '<<maxx<<'\n';
				if(Sum<0){
					printf("%lld\n",ans);
					continue;
				}
				query(1,0,n-1,0,n-1);
				if(Sum<0){
					printf("%lld\n",ans);
					continue;
				}
				Sum%=tree[1].maxx*tree[1].sum_d;
//				cout<<"!!!"<<Sum<<'\n';
				query(1,0,n-1,0,n-1);
				printf("%lld\n",ans);
			}
		}
		
		return 0;
	}
}
signed main(){
	return Y::main();
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

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

input:

2 4
1 2
Q 0 0
Q 0 1
Q 0 4
Q 0 5

output:

0
1
1
0

result:

ok 4 tokens

Test #2:

score: 0
Accepted
time: 1ms
memory: 5836kb

input:

5 7
2 5 1 4 3
Q 3 28
Q 0 39
P 4 0 3
Q 2 60
R 4 1 2
Q 1 22
Q 3 19260817

output:

0
3
0
4
1

result:

ok 5 tokens

Test #3:

score: 0
Accepted
time: 1178ms
memory: 30276kb

input:

200000 200000
613996 961471 536170 309149 407021 455240 358488 991078 61893 884024 149317 850785 867113 399303 403939 212239 258081 876122 195526 807123 889530 372732 596978 400631 815703 133663 994909 547857 947107 647857 602092 850543 843740 124903 157661 328300 638794 447455 172285 834119 422682 ...

output:

81822
121278
143252
126362
16581
178856
86671
68469
127057
595
81954
27570
175272
76862
154335
70499
188960
109086
44202
54592
99958
28255
119474
25525
164979
170755
139359
142050
34314
173021
79557
84051
50564
17355
29642
129463
6727
14150
199031
28186
18816
123494
15312
166472
130176
61250
180831
...

result:

ok 66992 tokens

Test #4:

score: 0
Accepted
time: 1174ms
memory: 32616kb

input:

200000 200000
677664 374441 486108 39782 781615 661561 141772 825921 695023 393138 698318 102384 993228 843812 973410 831844 415119 821190 385714 766834 256237 547865 215134 151991 511631 275965 609403 884809 573225 890238 855031 200295 301921 886311 562838 947371 977544 429646 606519 513605 687831 ...

output:

56965
140977
7834
178336
108471
91796
155954
182372
93575
37733
62468
11480
112106
88414
87113
105685
152203
14594
139563
166558
118418
82813
88219
96331
88490
103757
102389
97018
133314
118176
121986
131459
180984
118219
151852
102626
97903
2670
9672
21445
7813
106047
110484
173552
57057
8888
6379
...

result:

ok 66910 tokens

Test #5:

score: 0
Accepted
time: 1191ms
memory: 32616kb

input:

200000 200000
92935 736041 406602 39675 737386 774638 148037 265043 6620 783111 744860 12835 360542 521385 22328 673490 616602 714978 58663 432522 604694 796648 394106 298234 315853 320697 522498 259938 378139 807407 969855 340409 296829 793115 186785 855207 440612 141241 439553 772434 715317 491326...

output:

14293
93197
145550
121111
47880
108503
23017
180574
197492
142431
192745
8718
35907
8081
189258
37264
67619
192915
51446
101719
47103
194764
150940
70429
63689
80171
106198
47428
148646
34866
7640
55238
14505
48290
134184
153253
157023
139275
60107
19829
12458
73392
52498
35845
16149
29747
187258
69...

result:

ok 66650 tokens

Test #6:

score: 0
Accepted
time: 1188ms
memory: 32700kb

input:

200000 200000
662283 649676 842334 985779 320178 599599 878823 602649 514039 568148 866316 872051 156940 854423 343644 185859 181483 14888 46379 673131 418871 318311 116343 998225 668573 116075 978875 615620 658239 273410 982120 556772 388890 245817 441079 867694 338972 647170 954471 780196 810796 3...

output:

88791
76819
29852
34743
82581
44887
104801
98397
94061
75051
92967
42790
114986
94266
104874
117121
105012
14219
115927
11985
104888
162085
32737
85673
87052
126089
116376
77970
139431
46444
135044
148115
39672
115569
158852
43143
49530
19560
9787
28098
8504
126237
2357
128953
23569
1810
35530
14579...

result:

ok 66415 tokens

Test #7:

score: 0
Accepted
time: 1175ms
memory: 30060kb

input:

200000 200000
841978 148381 260767 703195 786413 466208 196890 424139 541288 59139 241364 449139 372823 664255 83994 668327 202584 500430 829059 551230 421323 869250 400737 618378 990902 374353 809001 218873 602410 598669 309887 66412 227146 253940 570787 437243 337461 767010 659248 295900 193797 54...

output:

10391
170413
155965
60570
38497
9888
133800
116334
120783
126247
179952
38883
126803
126792
118858
111033
6467
6942
125765
19131
35715
185820
135732
140536
117737
176740
96767
88742
43870
134665
21605
164835
7828
192777
131216
186908
53648
90406
27048
15417
60838
28916
41143
42921
88344
179681
2428
...

result:

ok 66892 tokens

Test #8:

score: 0
Accepted
time: 1192ms
memory: 30916kb

input:

200000 200000
110192 768617 990006 565328 658032 268041 347766 87053 870182 447700 307051 470357 761880 335411 122624 826303 440354 757276 370267 953206 48558 831593 152638 667650 120437 24531 221260 378239 868728 260674 324030 826791 823399 565212 192480 766540 200285 548993 226299 831768 56949 115...

output:

124970
88871
87648
94440
142800
76016
15293
153638
164391
182246
164615
59705
192155
78392
91895
40733
88730
103243
52533
5800
9213
196516
131122
13094
12278
91400
84995
180415
161899
97537
15583
142721
18390
137472
149245
162426
51218
6346
9670
126919
110248
148282
67094
59782
11030
138473
163905
1...

result:

ok 66787 tokens

Test #9:

score: 0
Accepted
time: 1177ms
memory: 29900kb

input:

200000 200000
248974 206838 309815 188125 615186 653243 955908 39878 449570 994349 638001 727730 116737 685369 506518 241761 567415 886757 736150 73276 884022 442575 798660 395046 644086 60711 718523 301989 793376 416747 324422 848731 610503 287217 586613 954128 313175 373216 210358 461072 290703 76...

output:

42084
195305
80859
151295
105418
153377
156368
106327
153020
87971
61090
117013
15148
56855
62334
163024
55520
98405
146580
159917
151377
24859
192023
103383
69483
174147
19581
143137
116215
110405
109829
104762
107929
118317
118748
115039
86781
144850
154276
139304
85558
13409
90549
53200
192205
16...

result:

ok 66966 tokens

Test #10:

score: 0
Accepted
time: 1194ms
memory: 30280kb

input:

200000 200000
751442 416238 760797 230299 674269 304670 363243 894902 826352 641466 692513 614786 922841 65251 906905 881926 191893 439937 623270 324402 545661 607389 967547 73854 872443 915110 50469 899358 395083 114883 282040 147472 146513 833216 668543 35674 22487 910097 382155 722057 414528 2474...

output:

14944
192275
6434
63172
179431
170158
132156
120709
62643
150422
110655
158468
50102
151024
69141
44106
195304
118416
13415
62863
66460
69062
63040
197705
124716
198732
161130
114324
123884
176593
1886
84270
51066
40161
59177
16494
6935
190269
10918
37708
63625
142607
80457
51851
53604
19315
83374
1...

result:

ok 66802 tokens

Test #11:

score: 0
Accepted
time: 1175ms
memory: 31904kb

input:

200000 200000
161513 49658 550142 797840 472281 25421 529706 742798 520598 556938 312051 36948 520149 231313 45352 110253 206492 437634 621624 775904 388312 621538 188436 179763 673080 580908 49788 754416 388644 444510 496462 659492 461003 62242 633602 344892 446035 530992 523395 60875 129314 284318...

output:

64993
28255
198124
126270
119717
85755
131709
174281
141217
71202
40355
85868
181018
84597
139885
40140
86117
103787
111993
10768
184569
81207
95945
112710
126458
147565
92494
24902
132138
99346
52837
22655
60844
102608
61399
142309
70211
53774
60271
45999
106392
25515
178062
105024
126001
36341
269...

result:

ok 66439 tokens

Test #12:

score: 0
Accepted
time: 822ms
memory: 32696kb

input:

200000 200000
19 85 70 6 100 11 205 109 57 28 75 151 248 134 240 20 168 233 60 193 156 32 70 191 163 144 39 36 14 145 192 187 144 13 202 229 47 139 87 14 243 145 72 223 169 68 178 93 192 131 351 404 342 372 411 348 432 423 391 309 375 377 262 258 436 372 312 483 310 485 277 410 477 314 319 311 282 3...

output:

155368
92597
176858
196781
137142
120187
130073
183165
128093
195956
150871
187412
182998
151093
129042
180282
50449
103555
131965
130591
152995
140261
170675
152842
75583
8980
133836
102884
30899
181373
189320
149688
11652
6607
89895
103713
107274
134788
18899
85749
131338
196441
64333
71057
178489...

result:

ok 66695 tokens

Test #13:

score: 0
Accepted
time: 817ms
memory: 32768kb

input:

200000 200000
73 68 139 20 51 188 58 88 111 99 83 199 243 77 177 115 204 133 83 148 245 67 121 244 204 56 182 66 34 206 48 213 126 124 164 178 102 122 63 164 84 113 148 27 109 17 42 57 230 243 347 469 326 444 341 446 307 467 416 327 289 363 415 333 295 296 337 359 489 392 346 439 438 374 406 400 360...

output:

139006
129913
182209
188420
72781
13795
178109
185024
29332
56190
93409
193667
138650
192390
125636
155214
199354
132003
65609
115433
44657
184697
48491
52757
146391
177203
185187
170024
99255
195378
184036
102266
120323
29603
178220
122775
123890
11377
55850
191745
83733
19619
154505
35690
194669
1...

result:

ok 66779 tokens

Test #14:

score: 0
Accepted
time: 818ms
memory: 31700kb

input:

200000 200000
22 200 117 164 109 59 54 88 115 175 147 163 124 35 67 67 61 42 216 134 242 160 122 165 54 224 43 169 112 229 118 103 164 16 194 58 78 249 65 26 20 87 133 5 56 126 11 183 206 31 294 253 443 323 395 410 437 355 325 484 492 299 321 418 416 278 410 296 431 471 339 428 273 426 463 489 255 2...

output:

38535
36940
55905
73803
175146
91489
140570
129309
67066
147403
82704
161557
115967
103632
125424
145337
151764
85591
174871
173744
120063
183490
136332
160745
169478
154541
96960
100389
123979
11530
124964
115734
137453
112840
53687
70998
98497
132429
114235
42590
123125
20811
126403
106872
129465
...

result:

ok 66445 tokens

Test #15:

score: 0
Accepted
time: 834ms
memory: 30084kb

input:

200000 200000
64 178 127 81 30 14 250 84 49 211 114 222 125 230 108 13 148 186 247 103 181 129 59 64 55 71 97 87 132 219 151 20 160 207 224 214 181 69 189 69 228 54 189 200 1 82 63 229 192 215 453 318 281 479 473 362 258 334 446 393 324 447 326 400 457 334 344 427 312 428 311 492 447 354 286 341 305...

output:

96165
124909
64424
95697
159064
46074
150312
99204
166951
128553
166565
135144
110956
86450
81434
181519
120722
118798
82801
24068
106783
120088
118070
8030
74021
109447
81139
169558
144104
71732
153921
176286
144139
148028
24630
98111
166540
191700
122969
61462
103470
111635
103052
175253
126799
97...

result:

ok 66234 tokens

Test #16:

score: 0
Accepted
time: 827ms
memory: 32708kb

input:

200000 200000
44 153 243 155 209 169 16 10 151 165 87 70 95 93 125 148 87 191 174 209 196 85 142 111 185 244 60 43 182 88 178 201 173 198 15 158 144 153 159 107 12 183 201 181 86 185 241 35 38 212 494 280 412 254 273 400 461 274 495 309 258 285 305 479 400 256 423 390 330 484 403 475 272 473 314 440...

output:

172333
140623
99577
168330
121766
73832
64088
54078
134838
81309
178278
9840
135305
185780
187874
130611
34553
64660
106933
139143
24802
134771
162373
133094
178642
137656
193069
127806
144297
77559
142669
159919
88895
154667
35175
182268
68301
12697
191178
127820
112110
7524
157967
11266
62427
1391...

result:

ok 66539 tokens

Test #17:

score: 0
Accepted
time: 847ms
memory: 32684kb

input:

200000 200000
320 364 333 285 415 152 365 218 267 437 269 31 294 61 121 478 233 347 100 120 231 369 6 121 69 161 470 448 354 242 435 148 432 193 67 69 363 131 112 232 65 55 402 104 413 208 111 162 387 323 112 226 160 429 68 477 163 173 453 463 236 413 116 188 52 462 378 182 182 173 173 58 340 168 13...

output:

126377
68538
102175
159740
159636
29517
10260
134400
16761
49793
126804
135747
165236
59030
125280
196043
12959
66423
148182
37918
139853
9409
192513
162922
181457
40674
62901
164873
89213
85791
51340
89024
147426
126057
190692
139734
105265
142449
127085
53523
138007
169403
166094
34736
114768
5429...

result:

ok 66678 tokens

Test #18:

score: 0
Accepted
time: 841ms
memory: 31172kb

input:

200000 200000
145 362 419 77 492 377 200 25 206 161 374 153 461 323 427 146 197 275 112 463 121 142 441 128 231 475 323 121 138 150 190 81 199 499 430 342 398 116 393 214 291 229 340 433 127 232 469 238 499 299 46 56 431 264 410 388 175 377 117 332 480 430 124 258 148 139 25 454 453 26 14 317 430 75...

output:

142208
177586
125224
165700
144187
194677
123277
113589
27861
194316
112836
134167
151622
91074
116747
64772
194886
126624
74450
25400
122034
178194
121441
171827
194019
32311
50676
181522
98467
187591
182258
97073
197670
118797
161659
183344
100671
88978
163840
167114
176844
97742
95610
103564
1634...

result:

ok 67090 tokens

Test #19:

score: 0
Accepted
time: 834ms
memory: 30020kb

input:

200000 200000
185 49 190 433 103 453 62 273 50 223 256 379 204 66 141 156 380 483 177 482 370 424 337 2 178 260 317 120 222 296 36 129 164 283 153 479 471 117 321 28 335 93 234 315 452 436 360 258 92 392 314 35 435 500 100 103 219 482 75 323 60 331 337 32 68 455 483 330 399 142 29 368 23 167 200 496...

output:

157423
109392
57015
131679
109262
116187
75071
98254
123216
152597
90071
113525
66930
114139
196395
126338
110090
32525
107441
71519
170050
37592
150241
95168
137309
164391
118080
147940
28840
101378
122979
3878
58979
167025
54978
78866
190935
22826
75225
125413
49426
154012
115181
114877
106532
102...

result:

ok 66692 tokens

Test #20:

score: 0
Accepted
time: 832ms
memory: 30776kb

input:

200000 200000
239 472 277 167 281 289 178 29 288 331 303 459 238 67 386 137 424 389 42 284 131 359 359 174 120 294 38 478 45 254 366 125 31 448 380 284 72 274 248 248 274 196 360 385 279 466 197 54 406 253 57 27 89 15 87 23 445 75 296 145 307 289 472 31 119 126 402 202 395 51 300 446 350 249 482 244...

output:

104698
120176
124679
197271
189062
111328
77432
154084
188264
129568
69518
123863
107973
188615
121510
87046
86721
147697
100854
93051
111059
86949
117869
12033
142219
158372
178313
83524
118379
94684
176078
104085
120252
97998
147266
193735
199727
144538
9340
199889
103861
104338
174765
50542
77970...

result:

ok 67026 tokens

Test #21:

score: 0
Accepted
time: 829ms
memory: 32632kb

input:

200000 200000
231 393 290 141 18 133 283 205 473 164 70 308 341 431 274 301 304 367 155 484 328 464 210 145 389 61 143 227 395 306 47 163 267 387 413 262 45 166 434 361 48 321 231 447 36 406 352 147 300 199 56 483 435 447 204 366 367 374 167 210 51 286 89 89 38 275 360 439 98 450 310 170 121 317 368...

output:

181939
5907
74396
125348
95499
134924
39134
124711
28618
129841
71386
120377
118875
93264
152101
192270
148992
153949
173977
108751
101997
158438
122841
188746
194095
126735
174495
178308
143207
26481
71940
144787
142623
7684
64038
153154
128458
119756
17820
126806
36259
153841
79813
96616
88871
186...

result:

ok 66518 tokens

Test #22:

score: 0
Accepted
time: 1008ms
memory: 31336kb

input:

200000 200000
2 4 3 8 10 9 14 10 18 20 6 23 1 28 30 16 29 36 38 40 42 2 42 48 50 52 54 56 58 60 62 64 66 30 17 72 74 68 78 80 66 82 86 88 90 92 23 96 98 21 92 104 106 108 110 12 114 116 111 120 122 124 10 128 130 132 127 136 138 82 81 144 146 148 57 21 154 156 158 86 162 164 166 168 170 136 95 66 17...

output:

5792
190386
15940
74043
181211
66068
36586
109463
148298
105100
23682
133338
144929
147720
4129
10098
40149
20673
43036
73275
34419
135782
55855
169742
102123
77099
90319
193639
68887
144452
59157
148441
155038
156267
121708
163130
168614
122445
48658
185476
153130
163741
25930
168663
13702
139349
9...

result:

ok 100000 tokens

Test #23:

score: 0
Accepted
time: 1003ms
memory: 30788kb

input:

200000 200000
2 4 6 8 10 12 14 16 18 17 22 24 26 28 30 32 7 36 38 40 24 44 33 48 50 52 54 56 58 60 62 64 66 68 70 72 37 41 31 80 49 84 86 88 90 92 94 96 12 100 102 87 106 34 110 94 101 116 118 67 122 35 4 95 130 132 134 11 138 140 142 144 146 148 150 152 154 7 147 160 162 164 94 168 170 48 174 176 1...

output:

180555
90840
167344
167853
145135
85874
149646
63937
66981
48143
190823
148419
80265
166014
76270
87020
5843
143397
145942
159931
131152
49934
131859
67642
110287
91342
139601
89052
51374
190023
147224
19672
149604
120635
195802
135704
294
13111
77496
191165
58745
12789
8827
169901
18545
165269
1371...

result:

ok 100000 tokens

Test #24:

score: 0
Accepted
time: 973ms
memory: 31416kb

input:

200000 200000
2 4 1 8 7 4 14 16 18 12 22 24 26 28 15 32 34 36 23 40 42 43 41 48 50 52 41 56 58 60 32 50 66 68 22 72 13 10 40 80 82 84 11 54 59 36 62 96 98 43 30 104 106 29 110 112 114 50 42 120 84 19 126 128 130 132 134 76 79 140 142 6 93 148 28 152 154 37 158 27 63 164 166 14 170 172 174 176 178 18...

output:

73719
66474
145981
142171
149460
16203
8290
123641
96772
50217
100773
24643
83241
116188
13216
28137
128719
16605
149415
131162
135545
160466
30734
157562
133119
134991
66641
58270
10573
10596
163297
61420
150502
146441
145668
64789
155628
157359
125833
158437
26442
86012
159703
81259
69027
149194
6...

result:

ok 100000 tokens

Test #25:

score: 0
Accepted
time: 986ms
memory: 32764kb

input:

200000 200000
2 4 6 1 10 9 7 16 18 20 22 24 26 17 30 32 34 32 38 18 42 44 40 48 50 52 54 56 58 60 55 64 66 68 70 72 74 76 78 80 70 84 86 56 90 92 94 32 98 100 89 96 106 108 110 112 114 116 118 120 122 124 126 128 130 132 134 136 138 140 142 144 106 103 150 152 154 156 127 160 162 164 166 168 170 172...

output:

133549
168098
174554
23871
164547
30601
32801
197500
190114
58864
23983
130848
177849
26333
116114
16869
30718
109671
76451
143102
126013
9001
117777
74461
86983
134287
20606
25704
152903
79408
62515
197832
27362
165167
167814
129069
134523
58894
118746
171081
180199
104224
153296
194937
85068
19767...

result:

ok 100000 tokens

Test #26:

score: 0
Accepted
time: 998ms
memory: 31340kb

input:

200000 200000
2 4 6 8 10 12 14 16 18 20 21 12 21 28 30 30 34 9 38 40 30 11 46 48 50 52 54 56 53 60 62 33 66 51 70 72 74 4 51 80 22 84 81 88 82 92 94 96 98 100 102 104 43 59 110 112 114 116 49 8 98 124 126 128 130 132 134 136 42 138 142 144 140 148 150 152 91 156 39 160 162 164 166 168 170 172 174 17...

output:

170367
108028
73255
75929
124874
181609
52983
80194
62938
3487
142268
182970
192227
197785
10681
196046
57128
86982
150124
10895
139697
21737
92706
140546
67084
184796
61705
95679
125571
141449
165227
162433
150054
134580
67018
59500
181325
154821
19164
2303
122898
111079
14501
30093
46635
46388
113...

result:

ok 100000 tokens

Test #27:

score: 0
Accepted
time: 1001ms
memory: 32708kb

input:

200000 200000
2 4 6 6 10 2 14 16 18 20 22 24 26 28 30 32 34 36 38 16 42 44 46 48 50 43 54 56 47 60 62 64 66 68 70 44 22 76 78 80 82 3 86 88 90 50 94 96 98 100 48 4 106 108 74 112 114 98 118 19 122 124 58 128 92 69 134 18 138 140 73 15 146 148 145 4 154 156 158 160 162 164 86 168 61 172 21 83 10 180 ...

output:

95023
67613
191606
121568
96291
61927
157410
171006
28098
1029
102603
174092
12067
138831
188855
175821
64872
87132
11980
52600
53432
192644
158920
180678
167584
96051
185447
52114
73300
176019
136467
77434
81765
4272
8489
196283
81695
40565
165080
16313
71416
129447
128073
68962
178822
153556
87484...

result:

ok 100000 tokens

Test #28:

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

input:

2000 2000
2 1 6 8 3 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 38 12 46 48 50 52 54 18 58 60 19 30 21 68 46 72 74 76 78 64 82 61 86 24 90 92 94 84 57 6 102 104 50 108 91 112 114 116 118 120 122 124 126 128 116 132 134 136 71 140 55 132 146 66 150 152 111 116 52 160 95 7 166 168 170 55 174 176 178 ...

output:

1856
1438
354
1035
950
669
591
1298
50
700
1579
1340
314
73
1338
1861
53
499
378
547
1622
615
1376
1383
534
1512
484
1763
452
1238
1153
265
866
814
1818
268
878
26
774
210
1951
233
1963
110
156
110
1010
1090
1372
1835
1487
574
454
1286
120
625
406
493
1987
680
1473
1420
1417
1526
1442
1891
1843
1570...

result:

ok 997 tokens

Test #29:

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

input:

2000 2000
1 4 6 8 10 12 12 15 18 9 22 24 26 28 7 32 34 36 38 40 42 22 46 34 41 52 54 56 58 10 62 56 66 68 70 72 74 76 78 48 82 84 56 88 90 65 94 96 98 100 102 104 106 68 16 58 114 116 118 120 31 124 126 128 130 2 134 88 112 140 142 43 146 148 150 140 27 156 158 160 59 66 166 168 170 172 174 71 178 1...

output:

1523
1168
1465
1717
148
1873
1432
467
1539
716
479
1025
1666
180
1429
968
1974
55
1389
856
941
984
952
380
1930
58
457
2
237
377
1582
322
1804
506
1538
756
1257
272
206
1163
1584
700
425
700
783
1586
785
1687
1460
1369
969
324
1369
185
447
856
569
55
1930
1847
1190
346
1433
82
954
846
829
1656
457
9...

result:

ok 989 tokens

Test #30:

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

input:

2000 2000
2 4 4 8 10 12 14 16 18 20 22 24 26 7 1 32 34 36 29 40 42 44 46 12 50 34 54 31 58 26 4 64 27 68 70 48 74 76 78 68 66 75 86 88 39 92 22 96 53 100 102 104 105 108 110 112 40 18 70 120 122 124 126 128 130 132 134 136 138 32 142 135 65 148 129 152 154 156 158 160 162 164 166 168 170 172 174 114...

output:

672
1883
1382
1339
1667
1728
1887
1215
773
811
1426
1447
1215
1905
260
1053
1658
120
271
1670
1831
290
388
1689
852
986
1931
870
24
1405
1299
1625
1769
131
591
464
657
1681
970
1130
593
246
819
979
727
256
1299
937
574
1095
1312
476
1020
411
1817
1083
533
1384
939
1017
466
1459
950
629
1120
355
1744...

result:

ok 968 tokens

Test #31:

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

input:

2000 2000
2 2 6 5 10 12 10 16 18 20 9 24 26 28 30 32 34 15 38 2 42 4 5 30 50 52 54 56 58 60 56 64 66 18 70 72 74 76 78 24 82 84 86 31 90 92 94 12 98 100 102 104 64 108 110 84 40 105 35 23 122 124 126 2 130 132 107 98 138 88 142 144 146 148 150 118 154 156 158 160 162 46 166 168 170 172 98 176 173 11...

output:

1460
675
1288
751
1277
1296
1565
1452
1642
1800
1631
1633
1640
1277
60
1109
1469
362
1685
468
477
279
1936
520
1847
39
873
1210
313
1753
811
1669
812
1316
1409
82
1948
1871
1670
289
1616
1798
1211
648
1125
1026
678
391
975
622
595
1061
946
499
691
661
431
440
482
371
367
1902
216
236
1399
295
779
14...

result:

ok 1026 tokens

Test #32:

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

input:

2000 2000
2 3 6 8 10 11 14 16 15 10 22 22 26 28 30 32 34 36 35 40 42 44 22 48 50 52 54 45 58 35 62 8 66 34 70 56 74 76 78 80 82 22 86 88 90 92 32 96 98 100 102 104 7 108 16 112 114 116 118 120 118 124 126 21 130 132 74 136 48 30 7 68 146 148 150 152 154 105 132 160 162 164 166 168 170 172 174 176 17...

output:

1809
1465
606
846
1058
458
507
1603
1513
1357
1536
152
1987
1518
1090
306
345
902
1889
1983
332
827
468
480
1541
268
1872
1864
587
420
417
415
549
932
1106
1347
1529
310
1915
946
1123
1439
1950
367
964
621
363
974
1220
593
1578
621
1723
266
1913
1348
1696
799
719
294
251
1274
1876
1830
1054
1186
381...

result:

ok 990 tokens

Test #33:

score: 0
Accepted
time: 4ms
memory: 4004kb

input:

2000 2000
2 4 6 8 2 12 10 16 18 12 22 24 26 28 25 32 25 36 38 40 42 44 29 48 36 52 28 56 58 60 62 64 66 68 70 72 44 10 46 80 82 84 69 88 48 54 94 96 98 100 102 104 106 108 110 35 114 116 118 120 84 124 45 62 130 132 127 76 138 140 142 35 78 148 150 62 26 135 158 160 162 164 46 96 55 32 174 176 121 1...

output:

1672
448
329
1224
586
1106
204
889
774
570
1438
483
1188
485
671
205
430
433
479
448
996
84
1600
404
1378
300
1751
1503
1748
1485
966
1690
1172
524
620
1714
1844
1350
594
1047
90
44
860
706
543
529
668
500
1365
113
1079
351
314
1474
967
903
407
105
1783
1239
1527
1853
1922
1752
994
1180
1744
1748
17...

result:

ok 1014 tokens

Test #34:

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

input:

2000 2000
2 2 1 8 10 12 14 16 4 20 22 24 26 28 25 32 34 36 38 40 42 25 46 17 50 52 54 56 58 60 62 64 66 68 70 67 42 18 78 80 64 84 86 88 90 19 94 96 98 100 102 85 106 108 95 43 114 33 36 120 122 94 126 77 130 126 134 136 84 93 142 54 90 148 150 152 154 156 60 160 162 164 166 168 170 172 174 176 19 1...

output:

432
603
318
1703
1205
763
1366
1693
24
344
1845
1641
1300
314
1193
438
651
762
1289
911
905
704
1008
1078
88
276
83
1252
1064
1383
1623
1527
970
1356
1718
717
263
1632
549
824
950
1642
1019
1497
955
1324
1630
675
45
1735
46
367
535
501
777
962
1856
963
656
1431
650
873
282
1894
985
571
859
632
640
9...

result:

ok 1008 tokens

Test #35:

score: 0
Accepted
time: 2ms
memory: 6028kb

input:

2000 2000
2 4 6 8 10 12 5 16 2 15 22 4 11 28 30 24 34 36 2 40 42 44 46 27 50 50 54 21 34 43 62 14 66 68 70 72 73 31 78 13 82 84 31 88 90 92 94 94 98 70 73 104 106 31 110 112 99 105 118 120 122 124 115 128 130 132 134 125 138 140 142 144 146 148 150 152 144 156 43 99 162 164 166 168 170 172 174 2 116...

output:

1148
786
1444
1935
1310
188
1590
41
1431
1692
131
1787
1062
1935
27
17
718
33
239
545
1022
1639
1473
304
1779
307
222
138
1735
235
1699
1802
577
622
710
1077
1300
792
749
1334
181
1528
267
763
1212
237
1789
1596
1104
375
1104
1843
608
670
143
1545
364
804
1014
1538
1425
310
823
1743
334
1142
112
165...

result:

ok 1033 tokens

Test #36:

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

input:

2000 2000
1 4 6 8 2 12 2 3 18 11 3 24 26 28 30 32 3 36 7 33 7 44 46 48 50 52 54 56 58 1 62 37 39 65 70 72 74 76 78 80 82 84 7 88 90 92 94 91 98 100 102 103 29 108 110 112 114 61 118 120 100 124 25 128 130 132 134 136 138 140 13 113 102 22 123 109 154 156 158 160 162 164 166 147 170 92 174 176 178 79...

output:

1437
1643
1604
1800
475
1110
136
1815
798
31
393
418
512
747
1473
459
853
1567
1905
488
601
1825
1229
1785
109
119
784
1908
548
1781
137
918
1898
1603
1948
24
48
124
1494
648
1596
1571
1661
1525
740
307
860
1702
1147
1576
1154
932
1487
1944
1015
1892
1989
1957
1814
1912
1938
1800
150
1740
1013
1310
...

result:

ok 1007 tokens

Test #37:

score: 0
Accepted
time: 4ms
memory: 6036kb

input:

2000 2000
2 4 1 8 10 12 14 16 18 20 22 24 26 28 30 32 6 36 38 5 42 6 46 48 50 52 4 56 58 36 27 53 61 68 57 72 7 76 11 24 82 84 86 2 20 92 70 96 95 61 102 104 4 108 22 112 114 105 118 32 53 61 58 128 62 8 8 136 106 140 142 144 146 148 150 107 154 51 158 160 21 164 166 116 170 172 174 126 178 52 77 18...

output:

1086
873
527
841
1022
945
914
1349
865
974
405
956
427
987
845
1219
1623
1178
158
1828
1654
1251
1085
344
212
1094
362
1531
143
1621
1098
1861
1423
769
529
1052
1547
1706
1056
811
516
1689
1416
1085
1903
1010
1880
680
145
1455
1149
294
583
896
1148
1148
23
1492
981
1119
664
636
198
619
1854
632
1800...

result:

ok 1026 tokens