QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#732228#8951. 澡堂sszcdjr100 ✓1551ms444292kbC++204.3kb2024-11-10 13:43:032024-11-10 13:43:04

Judging History

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

  • [2024-11-10 13:43:04]
  • 评测
  • 测评结果:100
  • 用时:1551ms
  • 内存:444292kb
  • [2024-11-10 13:43:03]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define double long double
#define mid ((l+r)>>1)
#define lowbit(i) (i&(-i))
using namespace std;
signed jp[1000010][20];
__int128 sum[1000010][20];
__int128 pre[1000010];
int stk[5][1000010],top[5];
int a[1000010],b[1000010],n,m,q,t;
pair<pair<int,int>,__int128> calc(pair<int,int> add,pair<int,int> ori){//premax prenum (extra add)
	int maxv=ori.first,k=ori.second+1;
	__int128 ans=0;
	if(add.first==-1){
		int cg=add.second;
		if(cg-k*t<maxv) ans=maxv-(cg-k*t);
		else maxv=cg-k*t;
		return make_pair(make_pair(maxv,k),ans);
	}
	int l=add.first,r=add.second;
	//ori del=pos/m
	//rel del=(pos-l)/m+k
	int now=l;
	for(int i=19;i>=0;i--){
		if(jp[now][i]>r) continue;
		if(b[jp[now][i]]-(k-l/m)*t<=maxv) now=jp[now][i];
	}
	if(b[now]-(k-l/m)*t<=maxv&&jp[now][0]>r){
//		cout<<maxv*((r-l)/m+1)<<" "<<(int)pre[r]<<" "<<(int)pre[l-m]<<" "<<(k-l/m)*t*((r-l)/m+1)<<" ";
		ans+=(__int128)maxv*((r-l)/m+1)-((pre[r]-((l>m)?pre[l-m]:0))-(__int128)(k-l/m)*t*((r-l)/m+1));
		k+=(r-l)/m;
		return make_pair(make_pair(maxv,k),ans);
	}
	else{
		if(b[now]-(k-l/m)*t<=maxv) now=jp[now][0];
		ans+=(__int128)maxv*((now-l)/m)-((((now>m)?pre[now-m]:0)-((l>m)?pre[l-m]:0))-(__int128)(k-l/m)*t*((now-l)/m));
		maxv=b[now]-(k-l/m)*t;
		for(int i=19;i>=0;i--){
			if(jp[now][i]>r) continue;
			ans+=sum[now][i];
			now=jp[now][i];
			maxv=b[now]-(k-l/m)*t;
		}
//		cout<<maxv<<" "<<(k-l/m)<<" "<<b[now]<<" "<<now<<" ";
//		cout<<maxv*((r-now)/m+1)<<" "<<(int)((pre[r]-((now>m)?pre[now-m]:0)))<<" "<<(k-l/m)*t*((r-now)/m+1)<<" ";
		ans+=(__int128)maxv*((r-now)/m+1)-((pre[r]-((now>m)?pre[now-m]:0))-(__int128)(k-l/m)*t*((r-now)/m+1));
		k+=(r-l)/m;
		return make_pair(make_pair(maxv,k),ans);
	}
}
void print(__int128 val){
	if(val>=10) print(val/10);
	putchar((val%10)+'0');
}
signed main(){
	cin>>n>>m>>q>>t;
	for(int i=1;i<=n;i++) cin>>a[i],b[i]=a[i]-(i/m)*t;
	for(int i=1;i<=n+m;i++) pre[i]=(i<=m)?b[i]:(b[i]+pre[i-m]);
	for(int i=1;i<=m;i++) stk[(n+i)%m][0]=n+i,jp[n+i][0]=n+i;
	for(int i=n;i>=1;i--){
		int bel=i%m;
		while(top[bel]&&b[stk[bel][top[bel]]]<b[i]) top[bel]--;
		jp[i][0]=stk[bel][top[bel]]; sum[i][0]=(__int128)((jp[i][0]-i)/m)*b[i]-(pre[jp[i][0]-m]-((i>m)?pre[i-m]:0));
		stk[bel][++top[bel]]=i;
	}
	for(int j=1;j<=19;j++){
		for(int i=1;i<=n+m;i++){
			jp[i][j]=jp[jp[i][j-1]][j-1];
			sum[i][j]=sum[i][j-1]+sum[jp[i][j-1]][j-1];
		}
	}
	while(q--){
		int x,cg; cin>>x>>cg;
		int pos=upper_bound(a+1,a+n+1,cg)-a-1;
		int tag1=x-1,tag2=pos;
		vector<pair<int,int>> vc[6];
		if(tag1==min(tag1,tag2)&&tag2==min(tag1,tag2)){
			int nows=1;
			for(int i=1;i<=m;i++){
				if(i<=tag1) vc[(nows+i-1)%m].push_back(make_pair(i,(tag1-i)/m*m+i));
			}
			(nows+=tag1)%=m;
			vc[nows].push_back(make_pair(-1,cg));
			(nows+=1)%=m;
			for(int i=1;i<=m;i++){
				if(tag1+i+1<=n) vc[(nows+i-1)%m].push_back(make_pair(tag1+i+1,(n-(tag1+i+1))/m*m+tag1+i+1));
			}
		}
		else if(tag2==min(tag1,tag2)){
			int nows=1;
			for(int i=1;i<=m;i++){
				if(i<=tag2) vc[(nows+i-1)%m].push_back(make_pair(i,(tag2-i)/m*m+i));
			}
			(nows+=tag2)%=m;
			vc[nows].push_back(make_pair(-1,cg));
			(nows+=1)%=m;
			for(int i=1;i<=m;i++){
				if((tag2+i)<=max(tag1,tag2)) vc[(nows+i-1)%m].push_back(make_pair(tag2+i,(max(tag1,tag2)-(tag2+i))/m*m+tag2+i));
			}
			(nows+=(tag1-tag2))%=m;
			for(int i=1;i<=m;i++){
				if(tag1+i+1<=n) vc[(nows+i-1)%m].push_back(make_pair(tag1+i+1,(n-(tag1+i+1))/m*m+tag1+i+1));
			}
		}
		else{
			int nows=1;
			for(int i=1;i<=m;i++){
				if(i<=tag1) vc[(nows+i-1)%m].push_back(make_pair(i,(tag1-i)/m*m+i));
			}
			(nows+=tag1)%=m;
			for(int i=1;i<=m;i++){
				if((tag1+i+1)<=tag2) vc[(nows+i-1)%m].push_back(make_pair(tag1+i+1,(tag2-(tag1+i+1))/m*m+tag1+i+1));
			}
			(nows+=tag2-tag1-1)%=m;
			vc[nows].push_back(make_pair(-1,cg));
			(nows+=1)%=m;
			for(int i=1;i<=m;i++){
				if(tag2+i<=n) vc[(nows+i-1)%m].push_back(make_pair(tag2+i,(n-(tag2+i))/m*m+tag2+i));
			}
		}
		__int128 ans=0;
		for(int i=0;i<m;i++){
			pair<int,int> tmp=make_pair(-1e18,0);
			for(auto v:vc[i]){
				auto nxt=calc(v,tmp);
				tmp=nxt.first;
				ans+=nxt.second;
//				cout<<v.first<<" "<<v.second<<" "<<tmp.first<<" "<<tmp.second<<" "<<(long long)ans<<"  ";
			}
//			cout<<(long long)ans<<"\n";
		}
		print(ans); putchar(10);
	}
	return 0;
}

詳細信息

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 0ms
memory: 22204kb

input:

1000 5 1000 1969617
59993 133807 154199 240894 438118 483699 540258 892751 922552 1049554 1092961 1153394 1287745 1315664 1372758 1550447 1634967 1817853 1825455 2023239 2064188 2117896 2250036 2453036 2492474 2794776 2917935 3047993 3153958 3163156 3237767 3443614 3664074 3716235 3801008 3822067 40...

output:

145473107761
145400375427
145403718605
145444938654
145438908460
145436948885
145405212826
145454120934
145460664260
145458475414
145433391640
145459823384
145401672860
145361079139
145486629489
145451768180
145426177956
145368877047
145384484360
145392373415
145514759762
145437334277
145471143810
1...

result:

ok 1000 lines

Test #2:

score: 10
Accepted
time: 0ms
memory: 24000kb

input:

1000 5 1000 36167
8215 12748 13176 18886 28740 44382 48915 49343 55053 64907 80549 85082 85510 91220 101074 116716 121249 121677 127387 137241 152883 157416 157844 163554 173408 189050 193583 194011 199721 209575 225217 229750 230178 235888 245742 261384 265917 266345 272055 281909 297551 302084 302...

output:

5383542
4273384
5583092
4487507
4540778
5739420
4991040
4831250
8044764
4747488
4297386
7059595
4985536
7791557
4450596
5708031
4408748
5511682
3977461
5126955
4570217
3960587
6060994
4619639
6617992
5548191
4048923
4200581
5648172
4915001
6247217
3840511
5690071
5159446
3355278
5730086
4592285
4686...

result:

ok 1000 lines

Test #3:

score: 10
Accepted
time: 0ms
memory: 24284kb

input:

1000 5 1000 26455
5755 9335 12488 13480 16017 32210 35790 38943 39935 42472 58665 62245 65398 66390 68927 85120 88700 91853 92845 95382 111575 115155 118308 119300 121837 138030 141610 144763 145755 148292 164485 168065 171218 172210 174747 190940 194520 197673 198665 201202 217395 220975 224128 225...

output:

3759363
2722461
1547992
1048857
2015166
2141100
1365260
3621432
2012670
2816278
953073
910376
959437
3872474
2174732
3202845
2220674
3598113
1366417
1009053
896353
856859
1073992
4270759
2501724
1112987
1322084
1846494
2453774
3339534
1661853
1633223
3031189
4018416
1709729
4499620
1118329
3768062
3...

result:

ok 1000 lines

Test #4:

score: 10
Accepted
time: 3ms
memory: 22244kb

input:

1000 5 1000 16722
3139 3641 7653 10814 14321 19860 20362 24374 27535 31042 36581 37083 41095 44256 47763 53302 53804 57816 60977 64484 70023 70525 74537 77698 81205 86744 87246 91258 94419 97926 103465 103967 107979 111140 114647 120186 120688 124700 127861 131368 136907 137409 141421 144582 148089 ...

output:

3512079
3034475
2734835
1941064
2519290
2440084
3414880
4562356
3334182
4126409
4618632
2050759
3791748
2933951
2726789
4788327
4132574
2963481
3636642
3025088
2699802
2034322
3616015
3451068
3111762
2892910
2940932
3444821
3086673
2603997
2440367
2753422
3618666
2391844
3572522
2602010
3080548
3836...

result:

ok 1000 lines

Test #5:

score: 10
Accepted
time: 0ms
memory: 21980kb

input:

1000 5 1000 60555
14667 19173 23801 42385 55686 75221 79727 84355 102939 116240 135775 140281 144909 163493 176794 196329 200835 205463 224047 237348 256883 261389 266017 284601 297902 317437 321943 326571 345155 358456 377991 382497 387125 405709 419010 438545 443051 447679 466263 479564 499099 503...

output:

10089512
17345531
7817544
13187454
10823659
10325209
13800175
11316499
12145244
12378466
11235075
13238408
18390405
9571104
15996985
7081670
14198216
16953216
10752423
8494916
17169941
7074729
9619075
16441956
14197611
15099449
9910334
12491708
13648701
9675595
10825715
9884233
13371337
15375812
824...

result:

ok 1000 lines

Subtask #2:

score: 20
Accepted

Test #6:

score: 20
Accepted
time: 897ms
memory: 427656kb

input:

1000000 1 100000 1165
83 197 266 277 299 529 538 601 629 760 792 1081 1208 1211 1387 1726 1873 1932 2198 2437 2448 2584 2715 2813 3113 3169 3207 3386 3934 4013 4032 4057 4137 4213 4396 4666 4754 4786 4856 4917 4966 5054 5124 5151 5196 5505 5548 5583 5730 5763 6031 6161 6169 6372 6446 6517 6712 6744 ...

output:

532526465394304
532526382684731
532526432382169
532526335149396
532526336776485
532526441654485
532526419072018
532526448365904
532526461590885
532526446716107
532526451559614
532526448428416
532526467783803
532526436578785
532526455446447
532526418608776
532526437618228
532526421765463
532526361938...

result:

ok 100000 lines

Test #7:

score: 20
Accepted
time: 715ms
memory: 427612kb

input:

1000000 1 100000 320
81 176 196 266 277 418 437 447 561 667 671 686 708 916 945 987 1077 1147 1343 1447 1459 1622 1739 1821 1907 2052 2211 2334 2483 2502 2553 2681 2879 2899 2996 3003 3075 3089 3141 3197 3312 3411 3450 3488 3525 3711 3870 4033 4066 4103 4216 4290 4341 4406 4500 4578 4600 4655 4697 4...

output:

110078125101649
110078095701794
110078065549730
110078084700891
110078055599406
110078147872941
110078125921229
110078050034681
110078131570282
110078020684010
110078081392840
110078123741061
110078124999461
110078092777746
110078093138994
110078104230505
110078088736720
110078130160314
110078088020...

result:

ok 100000 lines

Test #8:

score: 20
Accepted
time: 812ms
memory: 429636kb

input:

1000000 1 100000 6
1 7 13 19 25 31 37 43 49 55 61 67 73 79 85 91 97 103 109 115 121 127 133 139 145 151 157 163 169 175 181 187 193 199 205 211 217 223 229 235 241 247 253 259 265 271 277 283 289 295 301 307 313 319 325 331 337 343 349 355 361 367 373 379 385 391 397 403 409 415 421 427 433 439 445 ...

output:

5553833
8401453
8535183
8590839
6718701
6182541
5451207
4876437
6914671
6145580
8711335
8930675
5425001
5823370
6065908
7711946
7515358
5634147
4547534
5257419
6534174
5697110
6912866
4423285
8364102
6852541
6022633
6206653
5816343
6654555
6229974
8683850
5257837
5409556
4751045
5008105
6904326
4916...

result:

ok 100000 lines

Test #9:

score: 20
Accepted
time: 791ms
memory: 431972kb

input:

1000000 1 100000 16
16 32 48 64 80 96 112 128 144 160 176 192 208 224 240 256 272 288 304 320 336 352 368 384 400 416 432 448 464 480 496 512 528 544 560 576 592 608 624 640 656 672 688 704 720 736 752 768 784 800 816 832 848 864 880 896 912 928 944 960 976 992 1008 1024 1040 1056 1072 1088 1104 112...

output:

22191202
14316263
14215908
12574050
16955717
13552137
12066124
20974476
13340915
17693977
14052719
24225895
16771725
13796572
20050839
23326520
17991222
14412732
20532603
23738604
21615231
20091979
17370185
12410457
17205185
19921674
18529918
11452550
17698666
15112642
12609850
11971897
14779852
168...

result:

ok 100000 lines

Test #10:

score: 20
Accepted
time: 798ms
memory: 431716kb

input:

1000000 1 100000 7
5 12 19 26 33 40 47 54 61 68 75 82 89 96 103 110 117 124 131 138 145 152 159 166 173 180 187 194 201 208 215 222 229 236 243 250 257 264 271 278 285 292 299 306 313 320 327 334 341 348 355 362 369 376 383 390 397 404 411 418 425 432 439 446 453 460 467 474 481 488 495 502 509 516 ...

output:

6897928
10959197
5040880
7975693
6574287
5036014
10306570
9137913
8958373
4228311
7449261
9379706
9146142
10274232
4463961
10029845
7326894
7032260
6825277
5928071
8814749
4913978
8495037
6832887
4636661
12079588
3444995
7897528
7682909
5806085
10906552
7559878
8880934
10407655
7267429
3731886
11463...

result:

ok 100000 lines

Test #11:

score: 20
Accepted
time: 713ms
memory: 427680kb

input:

1000000 1 100000 54
10 62 114 166 218 270 322 374 426 478 530 582 634 686 738 790 842 894 946 998 1050 1102 1154 1206 1258 1310 1362 1414 1466 1518 1570 1622 1674 1726 1778 1830 1882 1934 1986 2038 2090 2142 2194 2246 2298 2350 2402 2454 2506 2558 2610 2662 2714 2766 2818 2870 2922 2974 3026 3078 31...

output:

999990099478
1000020712128
1000023784105
1000000426030
999967051898
1000028186354
1000005137696
1000007459992
999999989667
999972101077
1000003394026
1000016044861
1000002942535
999992373042
1000012218653
1000015238310
1000007382600
1000004402650
999992394498
999986392430
999993975864
1000011983527
...

result:

ok 100000 lines

Test #12:

score: 20
Accepted
time: 715ms
memory: 425876kb

input:

1000000 1 100000 40
17 56 95 134 173 212 251 290 329 368 407 446 485 524 563 602 641 680 719 758 797 836 875 914 953 992 1031 1070 1109 1148 1187 1226 1265 1304 1343 1382 1421 1460 1499 1538 1577 1616 1655 1694 1733 1772 1811 1850 1889 1928 1967 2006 2045 2084 2123 2162 2201 2240 2279 2318 2357 2396...

output:

500000527303
500000746017
499967503978
500007250648
500005291749
500004629820
499983324151
499980266264
499966351112
499993188438
500015774244
500004766707
499984969155
500018391637
500014807762
500009826386
500035131469
500022545533
499984841379
500022609759
499990934990
499995147709
500010680726
4...

result:

ok 100000 lines

Test #13:

score: 20
Accepted
time: 729ms
memory: 427916kb

input:

1000000 1 100000 54
35 88 141 194 247 300 353 406 459 512 565 618 671 724 777 830 883 936 989 1042 1095 1148 1201 1254 1307 1360 1413 1466 1519 1572 1625 1678 1731 1784 1837 1890 1943 1996 2049 2102 2155 2208 2261 2314 2367 2420 2473 2526 2579 2632 2685 2738 2791 2844 2897 2950 3003 3056 3109 3162 3...

output:

500002386443
499998979458
500011664725
500011341783
499993738944
500004137954
499981112418
499987830081
499991311719
500004379267
499986707484
500042817877
499981806306
500036313060
500006113447
499999655472
499958926623
499989600304
499950957577
499984617021
500009243539
500021262926
500017351824
4...

result:

ok 100000 lines

Test #14:

score: 20
Accepted
time: 705ms
memory: 427680kb

input:

1000000 1 100000 15
4 18 32 46 60 74 88 102 116 130 144 158 172 186 200 214 228 242 256 270 284 298 312 326 340 354 368 382 396 410 424 438 452 466 480 494 508 522 536 550 564 578 592 606 620 634 648 662 676 690 704 718 732 746 760 774 788 802 816 830 844 858 872 886 900 914 928 942 956 970 984 998 ...

output:

499999793763
500007843697
500005513979
500003594502
499996074937
499998537725
500004096012
500008735454
500004152454
500000568751
500010494658
500002699071
500012815225
499998928026
499999283522
500001200708
499997849850
499998173565
500000907455
499995094179
499996774856
500006115706
499997754467
4...

result:

ok 100000 lines

Test #15:

score: 20
Accepted
time: 722ms
memory: 427652kb

input:

1000000 1 100000 76
2 77 152 227 302 377 452 527 602 677 752 827 902 977 1052 1127 1202 1277 1352 1427 1502 1577 1652 1727 1802 1877 1952 2027 2102 2177 2252 2327 2402 2477 2552 2627 2702 2777 2852 2927 3002 3077 3152 3227 3302 3377 3452 3527 3602 3677 3752 3827 3902 3977 4052 4127 4202 4277 4352 44...

output:

499996922050
500001749644
499980553306
500033080378
499998189130
500013317917
500020273296
500036473243
499964461766
499993953371
499959801684
499968725060
499992480175
500055261991
499970920571
499967171328
500029720775
500055057585
500023488143
500020848450
499964139384
500021829831
499986689677
4...

result:

ok 100000 lines

Subtask #3:

score: 10
Accepted

Dependency #2:

100%
Accepted

Test #16:

score: 10
Accepted
time: 732ms
memory: 429728kb

input:

1000000 2 100000 1216
85 163 231 310 406 408 702 751 766 809 902 1012 1108 1232 1268 1688 1758 1824 1864 1865 1895 2035 2113 2140 2178 2298 2381 2634 2697 2784 2842 2853 3003 3120 3195 3204 3583 3586 3676 3680 3718 3826 3829 3870 3955 4042 4054 4100 4148 4252 4265 4369 4556 4575 4620 4661 4720 4875 ...

output:

254084390246421
254084444514764
254084291531315
254084384142563
254084409477840
254084335263872
254084322181731
254084347041244
254084434280345
254084374896618
254084355545069
254084362882291
254084400729316
254084301746015
254084404602665
254084351045759
254084343174263
254084318809635
254084321500...

result:

ok 100000 lines

Test #17:

score: 10
Accepted
time: 739ms
memory: 429728kb

input:

1000000 2 100000 1608
79 83 126 173 179 479 485 557 558 698 762 842 847 867 901 930 1041 1053 1098 1281 1286 1392 1777 1803 1892 1907 2007 2059 2161 2213 2399 2473 2481 2500 2655 2841 2881 2918 3293 3394 3440 3616 3679 3727 3733 3747 3910 3969 4120 4262 4274 4319 4481 4533 4617 4648 4839 4981 5057 5...

output:

352070399807716
352070448617669
352070536604326
352070468320558
352070398858548
352070411239582
352070456455899
352070432584577
352070517883528
352070519969148
352070509587775
352070499269195
352070465288114
352070441615058
352070526646224
352070467085876
352070494682033
352070470616712
352070524053...

result:

ok 100000 lines

Test #18:

score: 10
Accepted
time: 873ms
memory: 433820kb

input:

1000000 2 100000 45
15 18 60 63 105 108 150 153 195 198 240 243 285 288 330 333 375 378 420 423 465 468 510 513 555 558 600 603 645 648 690 693 735 738 780 783 825 828 870 873 915 918 960 963 1005 1008 1050 1053 1095 1098 1140 1143 1185 1188 1230 1233 1275 1278 1320 1323 1365 1368 1410 1413 1455 145...

output:

25980178
16524252
6280030
7754039
11893772
9111492
8721930
4791163
13942661
23174045
26456554
22233415
29158878
8415033
8794991
16600923
12421289
14236700
22634520
15158906
13570374
29132856
21047405
18148853
19519604
9762856
25452662
13315042
18940564
18938006
16601388
13498395
8202061
14562785
134...

result:

ok 100000 lines

Test #19:

score: 10
Accepted
time: 925ms
memory: 433828kb

input:

1000000 2 100000 16
5 10 21 26 37 42 53 58 69 74 85 90 101 106 117 122 133 138 149 154 165 170 181 186 197 202 213 218 229 234 245 250 261 266 277 282 293 298 309 314 325 330 341 346 357 362 373 378 389 394 405 410 421 426 437 442 453 458 469 474 485 490 501 506 517 522 533 538 549 554 565 570 581 5...

output:

4450394
4543787
3321805
2347818
6474298
6232851
2962999
1571959
2130828
1694195
676040
2423092
5817713
1710245
1164672
968461
2254704
2274722
6047798
3218163
1082861
4464415
2077141
3811061
2133263
1230875
1751534
1752637
4929612
3175533
2468822
1747309
1835893
5913095
2036167
3295451
4079568
157455...

result:

ok 100000 lines

Test #20:

score: 10
Accepted
time: 938ms
memory: 435872kb

input:

1000000 2 100000 14
12 12 26 26 40 40 54 54 68 68 82 82 96 96 110 110 124 124 138 138 152 152 166 166 180 180 194 194 208 208 222 222 236 236 250 250 264 264 278 278 292 292 306 306 320 320 334 334 348 348 362 362 376 376 390 390 404 404 418 418 432 432 446 446 460 460 474 474 488 488 502 502 516 51...

output:

4371664
1149698
2288064
3157587
5694227
6112424
4048899
4389517
3198429
2485355
2621065
934507
2356097
6243287
2249004
4533517
6226447
5360585
2856750
5503060
5252403
4216704
2379959
4754563
2391990
1288552
2719689
895073
5017701
4568985
5082080
2440989
1877704
3620036
1573222
2861483
3840190
401395...

result:

ok 100000 lines

Test #21:

score: 10
Accepted
time: 890ms
memory: 431752kb

input:

1000000 2 100000 9
4 8 13 17 22 26 31 35 40 44 49 53 58 62 67 71 76 80 85 89 94 98 103 107 112 116 121 125 130 134 139 143 148 152 157 161 166 170 175 179 184 188 193 197 202 206 211 215 220 224 229 233 238 242 247 251 256 260 265 269 274 278 283 287 292 296 301 305 310 314 319 323 328 332 337 341 3...

output:

4610258
4985649
4290412
6224530
3002901
5562199
5196866
4300782
4490252
3484338
3929683
4083871
6126389
7800077
3805116
3720592
6140011
7381134
4468253
3973708
3910037
3225091
5098460
4679840
3855085
7276130
5225689
5049992
5243134
3624560
4741899
3195651
3006782
6396331
5022462
5276078
3940234
6200...

result:

ok 100000 lines

Test #22:

score: 10
Accepted
time: 725ms
memory: 429660kb

input:

1000000 2 100000 89
1 73 89 161 177 249 265 337 353 425 441 513 529 601 617 689 705 777 793 865 881 953 969 1041 1057 1129 1145 1217 1233 1305 1321 1393 1409 1481 1497 1569 1585 1657 1673 1745 1761 1833 1849 1921 1937 2009 2025 2097 2113 2185 2201 2273 2289 2361 2377 2449 2465 2537 2553 2625 2641 27...

output:

250012001323
250024626240
249988006774
250003965208
250033614751
250023813893
249974662574
250011716811
250011485569
250000709083
250006045509
250002075671
250017178105
249987143213
250007774271
249973007922
250004321867
250011553618
250016862376
249998190531
250022503206
250018747884
249992634871
2...

result:

ok 100000 lines

Test #23:

score: 10
Accepted
time: 747ms
memory: 429724kb

input:

1000000 2 100000 97
11 17 107 113 203 209 299 305 395 401 491 497 587 593 683 689 779 785 875 881 971 977 1067 1073 1163 1169 1259 1265 1355 1361 1451 1457 1547 1553 1643 1649 1739 1745 1835 1841 1931 1937 2027 2033 2123 2129 2219 2225 2315 2321 2411 2417 2507 2513 2603 2609 2699 2705 2795 2801 2891...

output:

249973216061
249968463952
250022227255
250006173873
249994832945
249979828724
250000017818
250018211049
250021949069
249988400817
250033736568
249993253819
250024485856
249994288939
250001012626
249992411073
249957024288
249990927685
250010956461
249992292242
249981825219
249993932734
249962645316
2...

result:

ok 100000 lines

Test #24:

score: 10
Accepted
time: 693ms
memory: 429968kb

input:

1000000 2 100000 63
34 43 96 105 158 167 220 229 282 291 344 353 406 415 468 477 530 539 592 601 654 663 716 725 778 787 840 849 902 911 964 973 1026 1035 1088 1097 1150 1159 1212 1221 1274 1283 1336 1345 1398 1407 1460 1469 1522 1531 1584 1593 1646 1655 1708 1717 1770 1779 1832 1841 1894 1903 1956 ...

output:

250001589353
250005508338
250002966481
249997013385
249986424622
250010278110
249998305574
250006220758
249991447263
249996324178
250022070983
249999516349
250003332698
250007143904
250014386861
250007539338
250016150423
250000478130
249988863402
250021425924
249986281372
250018650394
249989311518
2...

result:

ok 100000 lines

Test #25:

score: 10
Accepted
time: 728ms
memory: 429728kb

input:

1000000 2 100000 98
87 92 184 189 281 286 378 383 475 480 572 577 669 674 766 771 863 868 960 965 1057 1062 1154 1159 1251 1256 1348 1353 1445 1450 1542 1547 1639 1644 1736 1741 1833 1838 1930 1935 2027 2032 2124 2129 2221 2226 2318 2323 2415 2420 2512 2517 2609 2614 2706 2711 2803 2808 2900 2905 29...

output:

250033498633
250027815709
250043839619
249991442877
249982588915
250009390364
250026759797
249992436756
249995749610
249970121372
250025027293
250012372515
249973134721
249966737193
249992921275
249982829138
249994655242
250027199958
250013032859
249999447735
250018076756
249992091116
249990054112
2...

result:

ok 100000 lines

Subtask #4:

score: 20
Accepted

Dependency #1:

100%
Accepted

Test #26:

score: 20
Accepted
time: 205ms
memory: 106440kb

input:

200000 5 50000 8448
68 1932 1956 2079 2363 3189 3837 3927 4312 4516 4526 4753 6972 7443 8556 9446 10246 11909 12189 12533 12576 12675 12739 13333 14022 14534 14827 15649 15946 16794 17011 17202 18405 18566 18855 19263 19294 19432 19934 19935 20100 20117 21221 21435 21437 21790 21956 21978 23322 2500...

output:

23828443987602
23828386511525
23828440401453
23828432234782
23828417976119
23828465058207
23828422731188
23828448201551
23828420115069
23828364736773
23828478665752
23828417536212
23828505579302
23828462228237
23828437377836
23828428117390
23828456395176
23828446664885
23828487887278
23828449221903
...

result:

ok 50000 lines

Test #27:

score: 20
Accepted
time: 207ms
memory: 109228kb

input:

200000 5 50000 8590
103 339 774 821 885 1011 1294 1351 3074 3230 3276 3941 4769 5185 5714 5941 6902 7574 8367 8449 8453 8977 9283 9381 9590 11468 11475 11733 12486 12586 13358 13800 14253 14580 14898 14963 15102 15578 15778 15860 16031 17047 18309 19101 19305 19724 20350 21158 22308 22567 22753 2291...

output:

24370390134431
24370391478289
24370319068102
24370435538692
24370392513002
24370501014902
24370449353937
24370384613440
24370401980945
24370365908891
24370455313241
24370458704500
24370395134637
24370422453218
24370387954135
24370398160446
24370407113413
24370486026795
24370431476353
24370493872347
...

result:

ok 50000 lines

Test #28:

score: 20
Accepted
time: 301ms
memory: 109100kb

input:

200000 5 50000 300
7 103 134 265 277 307 403 434 565 577 607 703 734 865 877 907 1003 1034 1165 1177 1207 1303 1334 1465 1477 1507 1603 1634 1765 1777 1807 1903 1934 2065 2077 2107 2203 2234 2365 2377 2407 2503 2534 2665 2677 2707 2803 2834 2965 2977 3007 3103 3134 3265 3277 3307 3403 3434 3565 3577...

output:

7618159
6959190
7090433
8125788
6101118
7691773
8851270
8154353
6589016
6115375
4293949
4130509
11585838
8622133
8341444
9619199
5887703
10764402
7441102
7601798
8958738
9467404
7126855
8194190
5727979
7943791
7012656
6333046
7865353
10550702
9765510
8251483
8273144
7402104
6001689
6295155
9026334
1...

result:

ok 50000 lines

Test #29:

score: 20
Accepted
time: 294ms
memory: 111264kb

input:

200000 5 50000 271
80 81 95 98 259 351 352 366 369 530 622 623 637 640 801 893 894 908 911 1072 1164 1165 1179 1182 1343 1435 1436 1450 1453 1614 1706 1707 1721 1724 1885 1977 1978 1992 1995 2156 2248 2249 2263 2266 2427 2519 2520 2534 2537 2698 2790 2791 2805 2808 2969 3061 3062 3076 3079 3240 3332...

output:

6158800
4403917
6594229
8772910
5361663
7443680
6358965
4652800
6034889
8584269
4991034
6987148
5192303
4875986
3465783
3981794
7334766
6526726
7423999
4430269
2839826
7152733
5204361
5525359
4344863
7396518
6017257
8644706
10004197
5672661
4637212
4806956
3928956
4594280
9818309
7682171
4790132
815...

result:

ok 50000 lines

Test #30:

score: 20
Accepted
time: 241ms
memory: 105452kb

input:

200000 5 50000 346
83 164 211 214 345 429 510 557 560 691 775 856 903 906 1037 1121 1202 1249 1252 1383 1467 1548 1595 1598 1729 1813 1894 1941 1944 2075 2159 2240 2287 2290 2421 2505 2586 2633 2636 2767 2851 2932 2979 2982 3113 3197 3278 3325 3328 3459 3543 3624 3671 3674 3805 3889 3970 4017 4020 4...

output:

22269407
12411682
14129630
16488349
10420562
13104102
11436945
19368031
11390721
15559467
12401765
21540932
21946906
18620750
14867132
23177928
16802804
18897764
17960026
20389811
15892554
17289376
12963156
13594568
17134998
14165135
17103054
13008327
14966895
13310379
15162394
16001699
13495521
181...

result:

ok 50000 lines

Test #31:

score: 20
Accepted
time: 279ms
memory: 107344kb

input:

200000 5 50000 131
30 30 33 97 103 161 161 164 228 234 292 292 295 359 365 423 423 426 490 496 554 554 557 621 627 685 685 688 752 758 816 816 819 883 889 947 947 950 1014 1020 1078 1078 1081 1145 1151 1209 1209 1212 1276 1282 1340 1340 1343 1407 1413 1471 1471 1474 1538 1544 1602 1602 1605 1669 167...

output:

2947071
3851685
5122334
4795621
6158109
3455051
3283654
2587446
3502892
6342975
4006931
3851585
3707221
4258767
1877588
4920339
2437732
5214888
3817546
4859471
3473573
3773372
4434501
5306512
4241391
2455209
4950931
2948723
2401972
3863424
2654143
2463789
2750967
3020336
2045101
6465779
2852230
2733...

result:

ok 50000 lines

Test #32:

score: 20
Accepted
time: 163ms
memory: 105176kb

input:

200000 5 50000 25
7 9 9 13 24 31 33 33 37 48 55 57 57 61 72 79 81 81 85 96 103 105 105 109 120 127 129 129 133 144 151 153 153 157 168 175 177 177 181 192 199 201 201 205 216 223 225 225 229 240 247 249 249 253 264 271 273 273 277 288 295 297 297 301 312 319 321 321 325 336 343 345 345 349 360 367 3...

output:

3999514580
3999622073
4000180715
3999735158
4000367268
3999778694
3999336483
3999738178
4000453254
3999920464
3999775478
3999244772
4000033418
3999892647
3999696457
4000048702
4000531119
3999480237
4000129161
3999926833
4000446643
3999772033
4000108207
4000041753
4000108438
4000024618
3999322076
400...

result:

ok 50000 lines

Test #33:

score: 20
Accepted
time: 176ms
memory: 105520kb

input:

200000 5 50000 462
27 196 208 224 427 488 657 669 685 888 949 1118 1130 1146 1349 1410 1579 1591 1607 1810 1871 2040 2052 2068 2271 2332 2501 2513 2529 2732 2793 2962 2974 2990 3193 3254 3423 3435 3451 3654 3715 3884 3896 3912 4115 4176 4345 4357 4373 4576 4637 4806 4818 4834 5037 5098 5267 5279 529...

output:

4002921454
4002761236
4000457885
4003278138
4012506884
3996745327
3994815416
4005200604
4001303989
4001112534
4008830198
4012717394
3998202264
3997931680
4010706331
3994413584
4011612065
4000194673
3991150929
4003394025
3989256774
3995215683
3994198220
4008049849
4002819752
4001522591
4010161812
400...

result:

ok 50000 lines

Test #34:

score: 20
Accepted
time: 184ms
memory: 108788kb

input:

200000 5 50000 423
77 155 225 399 407 499 577 647 821 829 921 999 1069 1243 1251 1343 1421 1491 1665 1673 1765 1843 1913 2087 2095 2187 2265 2335 2509 2517 2609 2687 2757 2931 2939 3031 3109 3179 3353 3361 3453 3531 3601 3775 3783 3875 3953 4023 4197 4205 4297 4375 4445 4619 4627 4719 4797 4867 5041...

output:

4001224153
4001887328
4006402687
3991585867
3997961117
4004174670
3993958904
3993508205
3996766718
3999026514
3993408671
3999158934
3988574697
3993575082
4000979106
3997004833
4009262490
3993662452
4002966670
4001296345
4007506300
3987394875
4011373334
4008024865
4004677527
4003493493
4002573044
400...

result:

ok 50000 lines

Test #35:

score: 20
Accepted
time: 346ms
memory: 108088kb

input:

200000 5 50000 34
19 45 51 58 91 117 143 149 156 189 215 241 247 254 287 313 339 345 352 385 411 437 443 450 483 509 535 541 548 581 607 633 639 646 679 705 731 737 744 777 803 829 835 842 875 901 927 933 940 973 999 1025 1031 1038 1071 1097 1123 1129 1136 1169 1195 1221 1227 1234 1267 1293 1319 132...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 50000 lines

Subtask #5:

score: 20
Accepted

Test #36:

score: 20
Accepted
time: 768ms
memory: 436108kb

input:

1000000 5 100000 1887
112 168 223 393 535 558 577 631 631 678 682 1043 1099 1268 1337 1396 1437 1472 1510 1587 1804 1984 2013 2290 2294 2392 2474 2547 2694 2717 2742 2841 2880 2906 2985 3030 3047 3064 3108 3275 3375 3440 3451 3488 3950 3957 3963 4047 4086 4335 4378 4448 4490 4544 4622 4864 4875 4897...

output:

138785143191754
138785158412509
138785225283652
138785104800924
138785118976960
138785112934741
138785059838322
138785084952748
138785129256978
138785072292366
138785090484906
138785174307446
138785204546881
138785189045551
138785131284055
138785130779155
138785104455009
138785163776264
138785127154...

result:

ok 100000 lines

Test #37:

score: 20
Accepted
time: 800ms
memory: 435804kb

input:

1000000 5 100000 1360
2 310 440 496 564 709 768 791 1013 1258 1401 1456 1793 1942 2004 2015 2248 2605 2731 2819 2887 2989 3082 3114 3182 3272 3473 3613 3629 3675 3710 3828 3889 3917 4046 4275 4295 4345 4381 4458 4475 4490 4537 4622 4630 4830 4971 5220 5340 5519 5535 5543 5551 5656 5813 5831 5992 599...

output:

86025085231915
86025033609884
86025032828746
86025084541224
86025092955724
86025048967786
86024962725044
86025042711478
86024945097968
86025034268426
86025063418806
86024964850623
86025040240190
86025018749987
86024965894645
86024989632159
86025034950005
86024966000623
86024944469476
86024947144447
...

result:

ok 100000 lines

Test #38:

score: 20
Accepted
time: 783ms
memory: 436100kb

input:

1000000 5 100000 1981
61 141 241 251 283 337 477 522 786 850 855 939 1037 1071 1223 1394 1560 1653 1807 1989 2118 2154 2397 2564 2786 2923 2957 2990 3029 3170 3229 3322 3432 3434 3473 3608 3703 3802 3896 3903 3932 3978 4107 4165 4229 4282 4346 4368 4380 4432 4553 4720 5482 5599 5641 5707 5727 5915 5...

output:

148126562715560
148126450284403
148126535856592
148126454999936
148126438027968
148126444188257
148126429009715
148126495799938
148126448656482
148126479317803
148126491583599
148126550596862
148126463496330
148126547985374
148126538529415
148126537793200
148126517972390
148126520140968
148126548816...

result:

ok 100000 lines

Test #39:

score: 20
Accepted
time: 817ms
memory: 435868kb

input:

1000000 5 100000 1434
34 185 481 631 667 683 709 869 1007 1095 1263 1283 1292 1546 1685 1803 1842 1884 1909 1965 2077 2203 2438 2474 2516 2744 2864 2993 3216 3224 3246 3301 3301 3311 3357 3367 3540 3593 3603 3615 3705 3833 3868 3879 3913 3979 4091 4156 4308 4460 4532 4601 4686 4867 4915 5057 5074 50...

output:

93474964897049
93474951196530
93474872493506
93474884173414
93474898306915
93474953505373
93474982428895
93474956302229
93474948675088
93474949769211
93474973453777
93474963941319
93474927557821
93474874803110
93474861494804
93474893221692
93475000934392
93474944214506
93474891490200
93474900163979
...

result:

ok 100000 lines

Test #40:

score: 20
Accepted
time: 790ms
memory: 435868kb

input:

1000000 5 100000 1871
377 446 596 666 716 857 931 932 1130 1132 1365 1442 1477 1524 1608 1619 1679 1795 1814 1904 2054 2137 2481 2490 2515 2584 2601 2843 2896 2910 3000 3126 3132 3156 3191 3212 3280 3287 3446 3450 3458 3510 3597 3679 3760 3807 3999 4139 4214 4431 4455 4496 4508 4516 4521 4554 4637 4...

output:

137120524285093
137120537416676
137120549259163
137120496973981
137120458025501
137120538226029
137120550231150
137120614453418
137120526712182
137120514246425
137120522483980
137120466515779
137120533333202
137120542210883
137120534265862
137120492554396
137120540002565
137120514969675
137120566996...

result:

ok 100000 lines

Subtask #6:

score: 20
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Test #41:

score: 20
Accepted
time: 830ms
memory: 435780kb

input:

1000000 5 100000 1148
66 270 289 469 666 1088 1140 1349 1424 1506 1634 1685 1735 1828 1853 1875 1965 1982 1987 2088 2182 2299 2342 2431 2866 2972 3125 3190 3386 3391 3450 3471 3550 3599 3772 3787 3855 4190 4293 4346 4398 4507 4525 4610 4645 4770 4944 4949 4954 5138 5222 5255 5282 5322 5333 5645 5763...

output:

64863445729482
64863431205695
64863412938677
64863454339983
64863511604271
64863379849612
64863441129751
64863474778445
64863410358441
64863415387822
64863438691327
64863434967987
64863431411500
64863349582723
64863492433253
64863485334037
64863507694395
64863409613530
64863437405791
64863450489463
...

result:

ok 100000 lines

Test #42:

score: 20
Accepted
time: 1499ms
memory: 444064kb

input:

1000000 5 100000 220
2 11 127 201 236 262 268 272 299 463 464 614 886 1229 1650 1656 1728 1881 1885 1960 1965 1972 2108 2110 2334 2577 2622 2624 2749 2911 2917 2980 3190 3227 3246 3260 3269 3366 3367 3453 3459 3537 3595 3688 3788 3859 3862 3940 3990 4001 4024 4184 4275 4381 4734 4750 4865 4870 4941 ...

output:

3955060
3954971
3954971
3954971
3954971
3954990
3954971
3954971
3954971
3955003
3954971
3954971
3954971
3954971
3954971
3954971
3954971
3955091
3954983
3955093
3954882
3954733
3954971
3954909
3954971
3954971
3954971
3954955
3954971
3954855
3954971
3954971
3954971
3954971
3955036
3954971
3954930
3954...

result:

ok 100000 lines

Test #43:

score: 20
Accepted
time: 1061ms
memory: 439928kb

input:

1000000 5 100000 55
7 15 30 43 51 62 70 85 98 106 117 125 140 153 161 172 180 195 208 216 227 235 250 263 271 282 290 305 318 326 337 345 360 373 381 392 400 415 428 436 447 455 470 483 491 502 510 525 538 546 557 565 580 593 601 612 620 635 648 656 667 675 690 703 711 722 730 745 758 766 777 785 80...

output:

8873462
5028147
7775993
11077599
7595929
8996822
8621741
7695279
10481047
5402686
7859471
8432287
7792004
6064598
8282646
13991846
11050965
8526679
5406081
7519801
12162329
4352748
11029069
9797700
7628638
12165264
7697412
8676093
7751830
2821081
10204982
7238197
15244942
13475661
3550835
9018988
91...

result:

ok 100000 lines

Test #44:

score: 20
Accepted
time: 1522ms
memory: 444256kb

input:

1000000 5 100000 46
14 19 26 42 42 62 67 74 90 90 110 115 122 138 138 158 163 170 186 186 206 211 218 234 234 254 259 266 282 282 302 307 314 330 330 350 355 362 378 378 398 403 410 426 426 446 451 458 474 474 494 499 506 522 522 542 547 554 570 570 590 595 602 618 618 638 643 650 666 666 686 691 69...

output:

270
267
271
270
260
269
272
258
270
259
269
270
264
262
263
271
262
270
263
270
255
264
262
261
259
260
262
258
262
269
270
270
269
265
270
269
266
265
267
268
271
258
272
260
267
269
268
257
254
258
265
272
271
270
263
267
269
267
263
255
260
271
267
270
269
265
255
263
268
263
270
270
260
271
269
...

result:

ok 100000 lines

Test #45:

score: 20
Accepted
time: 1122ms
memory: 443948kb

input:

1000000 5 100000 34
2 7 8 15 22 36 41 42 49 56 70 75 76 83 90 104 109 110 117 124 138 143 144 151 158 172 177 178 185 192 206 211 212 219 226 240 245 246 253 260 274 279 280 287 294 308 313 314 321 328 342 347 348 355 362 376 381 382 389 396 410 415 416 423 430 444 449 450 457 464 478 483 484 491 49...

output:

1032934
4595982
5133072
5989514
1723758
4555429
7222783
4861254
4379868
1412107
7102450
9096967
6329277
6082551
6377260
1865577
4715828
3993934
5048278
4325575
8172652
3416161
2138528
4618297
6515311
4869268
3010699
2238757
3355588
7148788
2817638
1768621
5185851
6848382
3770768
5525919
5171472
1996...

result:

ok 100000 lines

Test #46:

score: 20
Accepted
time: 1053ms
memory: 441960kb

input:

1000000 5 100000 27
5 7 9 17 26 32 34 36 44 53 59 61 63 71 80 86 88 90 98 107 113 115 117 125 134 140 142 144 152 161 167 169 171 179 188 194 196 198 206 215 221 223 225 233 242 248 250 252 260 269 275 277 279 287 296 302 304 306 314 323 329 331 333 341 350 356 358 360 368 377 383 385 387 395 404 41...

output:

4242804
5317463
3985758
4994772
4338465
3082185
5543389
3437453
3415925
3588869
5147749
3467830
4147381
5113550
3209418
3586896
6137451
4626734
2590397
5141634
4747081
4402674
4795408
3328403
3227322
4427053
5256550
3320877
4292967
3796544
4288891
4995111
3115591
3656790
4316169
4812541
4094347
3441...

result:

ok 100000 lines

Test #47:

score: 20
Accepted
time: 1551ms
memory: 444292kb

input:

1000000 5 100000 31
3 9 12 27 27 36 42 45 60 60 69 75 78 93 93 102 108 111 126 126 135 141 144 159 159 168 174 177 192 192 201 207 210 225 225 234 240 243 258 258 267 273 276 291 291 300 306 309 324 324 333 339 342 357 357 366 372 375 390 390 399 405 408 423 423 432 438 441 456 456 465 471 474 489 4...

output:

394
395
392
389
389
393
383
393
395
391
394
387
393
394
388
390
395
393
383
391
392
391
395
391
382
394
390
394
392
394
392
394
391
389
394
391
394
391
391
392
384
389
395
384
392
392
383
395
384
389
392
388
391
391
394
393
382
388
394
389
386
394
385
390
393
394
394
392
391
382
391
388
390
391
395
...

result:

ok 100000 lines

Test #48:

score: 20
Accepted
time: 1164ms
memory: 439964kb

input:

1000000 5 100000 34
9 12 32 32 34 43 46 66 66 68 77 80 100 100 102 111 114 134 134 136 145 148 168 168 170 179 182 202 202 204 213 216 236 236 238 247 250 270 270 272 281 284 304 304 306 315 318 338 338 340 349 352 372 372 374 383 386 406 406 408 417 420 440 440 442 451 454 474 474 476 485 488 508 5...

output:

3134594
6352729
4327571
6324569
5062560
3207075
3862472
6430854
4895668
2654968
3940795
2470961
3226845
4753121
3542183
4648857
7672367
2823777
3793267
3843727
4674543
2339553
2729936
6172437
3479171
3409061
4535160
4256549
3369204
4033583
4367706
2660548
4437064
3763141
3425368
3850751
3551944
4952...

result:

ok 100000 lines

Test #49:

score: 20
Accepted
time: 777ms
memory: 435876kb

input:

1000000 5 100000 76
9 16 33 62 72 84 91 108 137 147 159 166 183 212 222 234 241 258 287 297 309 316 333 362 372 384 391 408 437 447 459 466 483 512 522 534 541 558 587 597 609 616 633 662 672 684 691 708 737 747 759 766 783 812 822 834 841 858 887 897 909 916 933 962 972 984 991 1008 1037 1047 1059 ...

output:

100002259295
100000387512
100008986914
99999231173
99992466226
100008246257
99988812462
100003348972
99998272297
99999507042
99991933666
100003167179
99995020831
100004185476
99999026820
100004825183
99991208930
99995462164
100010514652
99997678254
99999861999
99998828662
100000091507
99999707139
99...

result:

ok 100000 lines

Test #50:

score: 20
Accepted
time: 733ms
memory: 436032kb

input:

1000000 5 100000 2
1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 5 5 5 5 5 6 6 6 6 6 7 7 7 7 7 8 8 8 8 8 9 9 9 9 9 10 10 10 10 10 11 11 11 11 11 12 12 12 12 12 13 13 13 13 13 14 14 14 14 14 15 15 15 15 15 16 16 16 16 16 17 17 17 17 17 18 18 18 18 18 19 19 19 19 19 20 20 20 20 20 21 21 21 21 21 22 22 22 22 2...

output:

99999689968
99999432898
99999621622
99999439590
99999343117
99999412375
99999378162
99999629560
99999368611
99999514561
99999458180
99999568445
99999623218
99999590640
99999607935
99999520420
99999493556
99999531937
99999567170
99999438927
99999356611
99999438741
99999470496
99999392996
99999495281
...

result:

ok 100000 lines