QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#855664#9971. 新本格魔法少女りすかDengDuck100 ✓14157ms26180kbC++142.5kb2025-01-13 06:51:332025-01-13 06:51:34

Judging History

This is the latest submission verdict.

  • [2025-01-13 06:51:34]
  • Judged
  • Verdict: 100
  • Time: 14157ms
  • Memory: 26180kb
  • [2025-01-13 06:51:33]
  • Submitted

answer

#include<bits/stdc++.h>
#define LL long long
#define uLL unsigned long long
#define pII pair<int,int>
using namespace std;
const int N=5e5+5,B=555;
int n,m,Cnt,A[N],RS[N],St[N];
LL Ans[N],S[N];
struct Line{int L,R;}Qry[N],F[N/B+5];
inline int Rd()
{
	int S=0;char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	while('0'<=c&&c<='9')S=S*10+c-'0',c=getchar();
	return S;
}
int Ch[N];
#define LB(x) ((x)&(-x))
struct BIT
{
	uLL B[N];int t[N],n;
	inline void upd(int x)
	{
		Ch[++Ch[0]]=x;
		B[x>>6]|=1ull<<(x&63),x>>=6,x++;
		while(x<=n)t[x]++,x+=LB(x);
	}
	inline void cl(int x)
	{
		B[x>>=6]=0,x++;
		while(x<=n&&t[x])t[x]=0,x+=LB(x);
	}
	inline int qry(int x)
	{
		int S=__builtin_popcountll(B[x>>6]&(((x&63)==63?0:(1ull<<((x&63)+1)))-1));x>>=6;
		while(x)S+=t[x],x-=LB(x);
		return S;
	}
	inline LL Qry(int L,int R)
	{
		LL S=0;
		for(int i=L;i<=R;i++)S+=qry(A[i]-1);
		return S;
	}
	inline void Upd(int L,int R)
	{
		for(int i=L;i<=R;i++)upd(A[i]);
	}
	inline void Clear()
	{
		for(int i=1;i<=Ch[0];i++)cl(Ch[i]);
		Ch[0]=0;
	}
}T;
#define In(x) ((x-1)/B+1)
int main()
{
	n=Rd(),m=Rd();T.n=(n>>6)+1;
	for(int i=1;i<=In(n);i++)F[i]={F[i-1].R+1,min(i*B,n)};
	for(int i=1;i<=n;i++)A[i]=Rd();
	for(int i=1;i<=m;i++)
	{
		int t=Rd();St[i]=Cnt+1;
		for(int j=0,L,R;j<t;j++)
		{
			L=Rd(),R=Rd(),Qry[++Cnt]={L,R};
			int BL=In(L),BR=In(R);
			if(BL==BR)
			{
				if(R<F[BL].R||L>F[BL].L)Ans[i]+=T.Qry(L,R),T.Upd(L,R);
			}
			else
			{
				if(L>F[BL].L)Ans[i]+=T.Qry(L,F[BL].R);
				if(R<F[BR].R)Ans[i]+=T.Qry(F[BR].L,R);
				if(L>F[BL].L)T.Upd(L,F[BL].R);
				if(R<F[BR].R)T.Upd(F[BR].L,R);
			}
		}
		T.Clear();
	}
	St[m+1]=Cnt+1;
	for(int i=1;i<=In(n);i++)
	{
		for(int j=F[i].L;j<=F[i].R;j++)RS[A[j]]++;
		for(int j=1;j<=n;j++)RS[j]+=RS[j-1];
		int Len=F[i].R-F[i].L+1;
		for(int j=1;j<F[i].L;j++)S[j]=S[j-1]+Len-RS[A[j]];
		for(int j=F[i].L;j<=F[i].R;j++)S[j]=S[j-1];
		for(int j=F[i].R+1;j<=n;j++)S[j]=S[j-1]+RS[A[j]-1];
		for(int j=1;j<=n;j++)RS[j]=0;
		for(int j=1;j<=m;j++)
		{
			int f=0;LL Sum=0;
			for(int k=St[j];k<St[j+1];k++)
			{
				Line v=Qry[k];
				if(v.L<=F[i].L&&F[i].R<=v.R){f=1;continue;}
				if(v.R<=F[i].L)Sum+=S[v.R]-S[v.L-1];
				else
				{
					int L=v.L,R=v.R,BL=In(L),BR=In(R);
					if(BL==BR)
					{
						if(R<F[BL].R||L>F[BL].L)Sum+=S[R]-S[L-1];
					}
					else
					{
						if(L>F[BL].L)Sum+=S[F[BL].R]-S[L-1];
						if(R<F[BR].R)Sum+=S[R]-S[F[BR].L-1];
					}
				}
			}
			Ans[j]+=Sum*f;
		}
	}
	for(int i=1;i<=m;i++)printf("%lld\n",Ans[i]);
}

詳細信息

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 13720ms
memory: 21236kb

input:

500000 50174
453952 363686 491616 32825 57465 422945 471561 73291 421205 416554 23295 133266 242225 330448 25039 340064 28713 465664 162059 323880 28978 273728 101338 161413 294941 214275 63951 267981 294251 202822 253124 272510 3268 37918 139343 385983 111577 311901 487665 482827 347449 416029 3065...

output:

37140482224
34639976441
43969281986
34161334900
43989474268
29265925652
42055490065
29273522769
34470649558
31057021177
45082279891
42633045968
24965661308
47949427314
39934839547
31946722251
32202412878
31922452884
44736436824
46173193393
35015845935
31452020651
33994126195
30526716598
43413051959
...

result:

ok 50174 numbers

Test #2:

score: 10
Accepted
time: 13619ms
memory: 21360kb

input:

500000 50000
483761 409384 371372 391186 181478 207855 91628 218748 274582 265418 253052 76826 15670 437134 6073 481510 474741 265520 496126 419159 129713 345118 468460 25917 365284 188440 218808 392357 8582 430707 365623 153604 139041 106196 150460 130300 252376 489428 395824 241387 368417 95440 33...

output:

33379126763
35734775083
46176544848
34597699495
37833169095
27623267186
41223330149
34969135626
32487873161
35347692293
35405163350
28110269917
25007599842
35432802577
32651348179
32686686317
26740651161
35614149923
47276786044
40221083758
46199666623
43754128347
28131948134
40539846117
22592070794
...

result:

ok 50000 numbers

Test #3:

score: 10
Accepted
time: 14157ms
memory: 21048kb

input:

500000 90715
49734 488827 125852 60078 137383 48439 427068 44266 117506 69998 16642 269329 353883 144088 292157 389881 97531 139928 333915 163713 404665 166720 281339 195742 418467 144699 274331 57762 268692 338157 220132 187518 298819 96797 306755 45962 406942 315596 356490 460108 463956 101319 382...

output:

35888285824
26764876032
10653070814
39337160910
21930922891
21442243870
36370719441
41260180731
30580404986
23044784230
32641136125
0
0
20863108454
21614113406
37764457044
44874592115
20661885950
38404479024
18595904595
40940254735
40165053614
34620161117
25280601626
10784676766
38298909955
21016956...

result:

ok 90715 numbers

Test #4:

score: 10
Accepted
time: 13595ms
memory: 25744kb

input:

500000 50000
291134 207563 447310 72447 38838 3515 39147 341181 361647 1924 476328 314573 183644 334035 219855 275784 377810 23132 454210 464626 287798 317687 254519 468395 489326 130572 11311 125296 67790 52266 144497 116583 382378 260995 402414 223239 226100 55165 73301 215043 91873 24811 339641 2...

output:

41073947456
40607097586
33679796170
41842893943
38796104412
37703142333
30346433451
37611524310
35316612170
34974750488
24299368876
37061330199
32576003404
44772832585
26059844010
34129371944
30293961536
37618588787
40619148396
48691220343
35401729070
38350434130
38579862826
41681073664
31600133804
...

result:

ok 50000 numbers

Test #5:

score: 10
Accepted
time: 14136ms
memory: 24900kb

input:

500000 90828
333911 7018 16483 277804 204197 92757 28372 160280 43961 163203 496222 151346 128573 1869 3345 312393 131651 392666 22186 325275 387569 287339 300079 448602 487422 74801 177015 187106 469588 478458 442770 260560 124563 418767 89390 228972 344500 106906 489555 247008 70020 201850 203669 ...

output:

25356760225
29886386356
12463099119
15117919802
34311221888
44775429652
32848277937
33690895261
33759585087
17734927355
19009379658
26408188898
0
18889620010
40161092181
31590459429
0
33701339404
24728824762
35471744190
40140736651
29069604298
39839363567
38006971849
8746987818
35637006564
415895271...

result:

ok 90828 numbers

Subtask #2:

score: 10
Accepted

Test #6:

score: 10
Accepted
time: 2140ms
memory: 24624kb

input:

500000 5
157360 289139 98034 293691 150262 268366 36782 147093 365410 444658 343224 375392 278298 357620 389673 167019 7747 119244 102126 83512 3649 459230 197365 245259 38071 249539 34617 213697 292553 389625 395778 280152 280038 239519 301475 232272 145919 370004 422791 271143 488283 185166 351026...

output:

50666226791
50440151159
50719090228
50631079493
50747050985

result:

ok 5 number(s): "50666226791 50440151159 50719090228 50631079493 50747050985"

Test #7:

score: 10
Accepted
time: 1807ms
memory: 22336kb

input:

500000 5
70752 248917 41910 13653 177839 45858 54229 174152 10090 332231 437916 391622 432270 53875 446421 91921 461870 243336 363086 249844 338371 495447 423857 350363 365324 255747 170681 435791 177298 199582 240768 449011 302158 378518 233809 267343 362784 187864 114604 322031 255693 54447 406202...

output:

48041849427
47573923544
48149375837
46484835228
62373267184

result:

ok 5 number(s): "48041849427 47573923544 48149375837 46484835228 62373267184"

Test #8:

score: 10
Accepted
time: 2031ms
memory: 22012kb

input:

500000 5
241608 419462 82981 424356 17797 426283 105137 396042 362939 472171 51823 373467 302031 234957 103628 345691 280071 391667 370350 226645 393628 99397 111403 124617 289298 487366 430929 445895 146724 165853 250446 134811 333218 232414 263197 300887 194261 147235 493474 305082 109715 82765 16...

output:

50381279295
50436234418
50754046820
50457636384
51060372228

result:

ok 5 number(s): "50381279295 50436234418 50754046820 50457636384 51060372228"

Test #9:

score: 10
Accepted
time: 1807ms
memory: 22668kb

input:

500000 5
384662 360905 151827 77657 463152 472106 142072 464841 224605 243338 468024 153983 367505 347441 107735 63958 144215 118222 294699 106900 236160 308499 164080 9056 373110 343094 108210 164120 416292 77276 327997 344605 375908 60401 331692 169348 431340 174229 301328 62849 130369 272892 1802...

output:

47987223119
47114724607
47699758559
47424207451
62476342231

result:

ok 5 number(s): "47987223119 47114724607 47699758559 47424207451 62476342231"

Test #10:

score: 10
Accepted
time: 2045ms
memory: 20092kb

input:

500000 5
454113 396339 270960 34848 390907 416021 317393 9900 333318 50842 198100 115 286821 210759 79669 257489 94065 308047 220510 343737 11392 410497 58962 488921 315855 115533 11194 298501 112352 81722 415920 175976 463840 491310 29020 479390 494454 375738 37344 278711 347144 351121 38809 194902...

output:

50554118536
50349176037
50371935305
50817175419
50798953918

result:

ok 5 number(s): "50554118536 50349176037 50371935305 50817175419 50798953918"

Subtask #3:

score: 80
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #11:

score: 80
Accepted
time: 9679ms
memory: 25248kb

input:

500000 708
93184 5984 221047 279293 443862 362913 154809 330374 322044 116472 121600 129892 155673 125791 108495 102753 29993 343482 330610 334568 191288 203277 228651 99077 134137 174507 1813 76557 180344 494079 44549 44355 31436 413608 434136 182751 491424 260122 451560 132868 446024 312359 310556...

output:

47779489344
48047947143
47623594027
48177835747
47918424877
47931225548
47660914297
46658964900
46816574829
47594644277
46377128758
47631748202
47166089850
47511016716
47421738786
45826108264
47836547685
48131785169
46825373091
48320449502
49060378817
48253607658
48139996378
46543789787
48307807311
...

result:

ok 708 numbers

Test #12:

score: 80
Accepted
time: 8443ms
memory: 24520kb

input:

500000 576
486876 220703 252561 191936 325554 124182 290243 485249 194809 72237 172996 222585 466309 44008 209566 325917 427491 333404 15075 377271 172799 421025 314389 176993 238629 359145 252082 138138 342996 349552 10028 434272 423848 435910 331035 136708 300727 362672 154988 9533 56995 432614 24...

output:

47386714212
48474225914
47589165059
47697398297
47502912892
48220857086
48450095086
46999736904
47511564419
48236128565
47526182169
47309834669
47544609920
47448841917
47754207398
47105567987
47856068346
47347844783
47831565501
48299960443
48264882588
45089911919
46912280249
47365999573
49760969074
...

result:

ok 576 numbers

Test #13:

score: 80
Accepted
time: 9643ms
memory: 24296kb

input:

500000 712
281917 259619 365666 20309 7714 58460 480950 278368 265411 376406 159178 142407 182630 158927 131415 9637 204319 116741 435926 210767 116446 121117 486654 285813 244669 16593 277892 279800 442580 342520 319644 131765 376202 343002 216859 414985 237867 255479 446911 358727 106184 392592 29...

output:

47283290587
47610631868
47317335160
48341334788
47903586358
45847557083
47113110732
47995909540
47902026027
47578762692
46672906836
47315335651
48489135956
48114516272
47685148650
46683555115
47908072286
47551979975
48751729200
48617228552
47913378604
48644565125
47875733683
47596195914
47528005190
...

result:

ok 712 numbers

Test #14:

score: 80
Accepted
time: 8192ms
memory: 23436kb

input:

500000 561
167526 56233 391855 261652 244043 101491 364438 200488 124721 258554 29288 452552 47399 73754 497906 148279 436908 331363 194231 421347 140796 409051 345404 75759 375948 398500 460617 120676 142758 307902 398762 130287 33525 1185 443884 36398 179252 164658 455263 372642 383127 76020 44606...

output:

48377688492
47685161156
49024279503
47630629780
47652035142
49475844592
48811800062
47736159471
47272777917
47906433779
47311889490
47376128095
48141379943
48063797126
47737885296
47537412929
49038013976
45937614657
48906919192
47518777256
47853210471
47591318613
48393314422
47508616364
48553353744
...

result:

ok 561 numbers

Test #15:

score: 80
Accepted
time: 9050ms
memory: 25080kb

input:

500000 724
171292 40915 376777 467670 288190 28934 192465 154107 331041 335407 197655 55539 216582 387790 277800 285410 216031 265926 342494 133603 242935 314057 217631 191184 117836 24876 233867 9100 370739 312240 33279 109206 349098 165060 484384 447832 116714 328893 277031 248830 149139 352093 34...

output:

48065309368
46763257466
47153232156
47619794483
47672884782
47770100959
46657883593
48925239150
47040453318
47915140714
47865479823
47567397836
47666244827
47788190813
47918867529
46191532226
47840897093
46863438069
48154578841
46913703900
43303960517
47256184319
46759226089
47608598676
47504726102
...

result:

ok 724 numbers

Test #16:

score: 80
Accepted
time: 2094ms
memory: 20612kb

input:

500000 10
437813 486614 463236 491350 421235 451729 491018 445586 459305 451562 485000 496084 481494 470414 475691 491732 481842 465979 495159 491889 462353 472163 475026 484999 476520 472922 488745 482337 492624 494156 415429 497372 466105 466321 461106 485082 494283 442451 450174 471690 448892 496...

output:

30404407968
43541253809
30985031810
33570967163
46997524109
31583588715
36901146321
43390423242
37074111303
36909278128

result:

ok 10 numbers

Test #17:

score: 80
Accepted
time: 3075ms
memory: 21192kb

input:

500000 30
464907 483220 496750 467223 472657 497355 453474 488854 423933 454272 452309 474050 499039 495728 443186 471975 464407 494584 410584 475679 461489 488692 491319 464863 478509 472053 469770 492129 489593 487604 467149 383037 499962 469720 475108 456435 491100 495880 498741 426577 402400 490...

output:

29323550298
29238867057
27997386334
28373023304
32249727249
26612127362
28746129035
29891704469
31278632508
29180181503
29452698582
29195895339
28679549559
29183036011
29060972516
29294603891
29146557646
26858107751
31355580520
29211131610
28983439502
29463792401
29289529734
29060906787
26358205744
...

result:

ok 30 numbers

Test #18:

score: 80
Accepted
time: 3381ms
memory: 24800kb

input:

500000 50
499994 477356 454947 469481 486680 471261 474107 492277 473074 459535 447338 452562 497441 489495 453548 471512 496023 454341 470906 498839 489471 437388 448275 438417 489326 481009 471439 483676 499917 490939 498423 498030 452377 494363 450310 468835 440469 452279 447975 499915 413869 379...

output:

28000989296
28427817681
27889879898
26660565669
29534693692
28225073559
27948893113
27740510148
26746108721
27375199354
28989385337
28254811031
28093397735
26952122037
27534773887
27533129587
27880075014
26629527145
26859760435
29519397191
27593246230
27370690475
26612092333
29650631035
26534922322
...

result:

ok 50 numbers

Test #19:

score: 80
Accepted
time: 3586ms
memory: 19692kb

input:

500000 80
448139 482654 373609 454544 498988 482676 453563 408116 498936 483219 492157 417208 414975 410378 488999 479895 437773 485174 465966 381400 428015 487421 471282 471981 443960 460688 464861 492633 483854 459529 477519 414378 485137 489911 494338 486838 467187 464164 497488 487394 498855 465...

output:

27229958821
27435346490
26758349017
27007906853
26495290987
27418253972
26252880570
26697692848
26995058988
27093574934
26307775229
27191820646
26465812031
25527942102
26466242044
27884894060
27658178024
27797848026
26408274912
27436355227
24859214392
26538427417
27963607243
27307893651
27039875907
...

result:

ok 80 numbers

Test #20:

score: 80
Accepted
time: 3778ms
memory: 19692kb

input:

500000 120
425851 486770 493345 497394 430377 499399 432703 477556 488807 498146 329225 481524 453583 491317 482738 460103 462701 485726 493334 483967 485865 449861 495492 499475 380471 466461 422793 456264 496924 489965 482050 455879 483776 485128 461238 496607 482536 449775 466962 496592 452502 45...

output:

27268465505
26970495839
26812337109
26529690291
26152750561
27572574232
25418093859
25910023945
26467828590
25891021670
25842778293
26702359917
27522515056
25089137844
26817832463
26180241975
25951211012
27423141371
27036352133
27178146478
27918627713
25270030513
27014286095
26296804048
25912278248
...

result:

ok 120 numbers

Test #21:

score: 80
Accepted
time: 4153ms
memory: 22064kb

input:

500000 180
442771 493385 463982 424611 492674 491516 482911 499564 373583 448642 464099 468317 467696 463588 480361 463512 482907 392805 437882 453747 469269 482925 483534 487401 483446 493878 483546 470030 464586 385883 480186 452991 457332 453879 481635 480059 292016 379255 438026 486978 480919 46...

output:

26552793361
26783611530
26354016213
25901475429
25625363838
25395986667
25921584983
26374056619
26731453243
26395130087
25881100894
26189282926
25044280307
24722457963
26335993883
27761287923
26287938438
26974795994
26698759474
25388206981
25306618712
25081748766
26799085200
27138292573
26090541976
...

result:

ok 180 numbers

Test #22:

score: 80
Accepted
time: 4623ms
memory: 20776kb

input:

500000 250
485548 486645 454586 499381 338992 445866 482562 489644 497644 499125 498688 441828 489366 489798 476759 494012 465534 491999 475885 499317 481719 473417 462940 429604 462279 443276 410057 499885 485046 484093 454267 448148 499858 489417 495208 466561 473901 453344 486627 393119 486306 49...

output:

25675940477
21983595563
26805111407
27353170636
26478629985
26745301254
25411247202
26660407244
26459585745
25619895379
26398451124
25945020227
25259164539
26086275893
26367971867
26225775624
24510569394
25487382007
25961306358
26287019166
26648227700
28799218644
26234796358
24864904929
25518936434
...

result:

ok 250 numbers

Test #23:

score: 80
Accepted
time: 5682ms
memory: 24604kb

input:

500000 400
481398 498300 466236 487017 487289 488674 476604 493368 486067 499158 488613 485714 488951 419843 495519 486986 466876 416535 488819 467321 484460 438297 487047 437135 492249 493983 495691 460611 475583 440811 469973 429590 484922 476716 480920 482068 495637 462089 492457 458502 467280 35...

output:

28251516710
26424751137
25998551529
26471441872
22577211742
24976593597
26857457240
27333957499
26458812903
25723021138
25432089387
26120967009
25569724341
25195531006
27544375665
25967741328
26351362748
25624757476
25927790174
26846959807
27018235405
27083085876
24242448934
27060188721
25627239153
...

result:

ok 400 numbers

Test #24:

score: 80
Accepted
time: 6763ms
memory: 19800kb

input:

500000 600
466482 491808 487733 464893 482968 478664 488568 459605 497817 455703 491224 484289 482797 480053 383977 388961 365878 490575 498618 457577 477741 492617 496588 495848 496789 493707 482037 493068 494864 481659 464582 451023 493518 430738 481297 468173 488005 479672 440713 432021 494982 49...

output:

26824951599
24485230121
27558690809
25899123446
25604640894
24093302475
25856608399
25214356025
26135781598
26298148297
26399786980
24159108925
25273610840
24968078257
25246359422
24497920548
24040697321
28790597420
27421400920
27512277886
25017260873
25812609435
27017107938
26399468147
27244335228
...

result:

ok 600 numbers

Test #25:

score: 80
Accepted
time: 7554ms
memory: 24404kb

input:

500000 800
499380 441572 459689 495318 485559 476531 449353 492094 485842 495981 468081 470016 455706 496284 492419 408300 463154 488363 497148 464486 436681 498988 494324 489253 477886 474900 473546 491167 463871 475714 490912 433207 442923 389683 450383 476742 461861 490885 499467 489400 448422 48...

output:

24190532102
26032944536
25254307787
27158940253
24126287965
26565484733
27291205366
24692991646
26265056917
25331193567
27309208166
26702863805
25845380968
28255237242
27701806561
24771368920
27260669110
24507808743
26240308686
26687639066
25988022769
27241109568
25040039351
27023033104
24147451995
...

result:

ok 800 numbers

Test #26:

score: 80
Accepted
time: 8046ms
memory: 24128kb

input:

500000 1000
422542 475808 377785 471032 491544 485048 495748 490642 382114 476616 399666 489931 467134 390700 474692 471303 462207 495665 465217 490053 460642 421674 433176 487116 464910 401867 432663 452614 485822 462056 456511 406601 425621 494439 443881 488952 456059 483379 440461 432754 471189 4...

output:

24713349079
26577340289
26517828578
24801052664
25031380141
24856114922
26575604616
29472345642
29596491801
27586530175
26982249982
25485057550
26482179790
27575105908
26395346510
23900576355
24028110614
25601447273
25004162194
28864306604
29711820523
26286971160
24937556083
25425394125
25347649722
...

result:

ok 1000 numbers

Test #27:

score: 80
Accepted
time: 8387ms
memory: 24480kb

input:

500000 1200
444163 482670 453024 491483 408465 467549 489493 486396 470991 488115 429203 498606 493981 473557 495659 482163 428414 435877 404243 424121 493708 355849 450183 481060 465667 484865 480146 399336 478071 342249 437590 356860 482439 491039 479303 447399 498078 477564 467190 480054 486728 4...

output:

26437334254
23471730620
29525961940
22217835221
27291511875
24337516711
25978252953
29730616316
26011094385
25475929927
23613343765
24841857357
25997125959
25830693948
27131589790
26351909804
27540235881
22827848038
24634590081
27299213740
23296353022
27437926554
25505523597
26260606832
27777437955
...

result:

ok 1200 numbers

Test #28:

score: 80
Accepted
time: 8854ms
memory: 24176kb

input:

500000 1500
476347 492292 465814 484684 461224 394519 475362 472759 465807 496193 468393 499230 493648 432772 473789 478710 433103 496205 499141 491208 492995 352098 343843 497709 486729 497252 471840 471426 439641 490803 411385 484654 498172 468428 443255 498152 439234 461539 471450 437946 437499 4...

output:

25268391034
25348098004
26962631807
23995230190
23958320936
21722732199
26417717296
27045479927
23552241054
24018111789
26703298435
23084256843
26458460924
29293859250
27431575819
23055278021
22686932683
23835435046
26329215120
25563545334
25073612236
22850385193
26093651552
26106545551
23715761319
...

result:

ok 1500 numbers

Test #29:

score: 80
Accepted
time: 9158ms
memory: 22424kb

input:

500000 1800
425397 359002 483658 490503 468200 475955 470614 489182 478773 281641 465582 484847 464697 490792 472608 493157 494625 496635 467674 425010 496154 497189 497095 484695 465709 497882 479922 497859 461875 474804 491853 488109 430018 406268 498945 486135 479366 484070 484811 494166 436073 4...

output:

24900161034
21561912668
26302682502
24759435733
25017490039
25687887200
29821263987
25921580949
29849647932
26253674432
26190944962
26858792741
22817879751
29447261208
25151655450
26559000915
24394647354
22216572218
26055421945
23242562835
25641261000
22251898833
26345541128
21650003464
25786344678
...

result:

ok 1800 numbers

Test #30:

score: 80
Accepted
time: 9622ms
memory: 24132kb

input:

500000 2400
489897 450888 495681 499799 477118 465073 441510 463412 496128 476012 489067 468899 487981 426187 434376 487404 462379 492045 398392 476222 472665 478707 493197 467018 464887 443986 445416 464156 428763 381779 493242 487804 491963 494262 334653 455411 480724 467255 432558 433606 461408 4...

output:

28110463163
26310141299
25823636107
23867069767
26730068204
21620581199
24022639448
23835101891
25385391153
24268425762
24288783653
30419141431
25981130332
24707108947
25498527302
20463777806
25391764038
22748725715
26285054800
24502362992
27527214919
29838261954
26173761518
29229043720
25943187267
...

result:

ok 2400 numbers

Test #31:

score: 80
Accepted
time: 9866ms
memory: 26180kb

input:

500000 2800
487401 499328 487974 434969 469454 416689 499500 482852 484829 446581 424659 449280 447724 481306 489417 465439 495336 467258 492926 463672 474620 437573 481232 497300 479886 453239 496973 458516 498465 426647 497117 478689 466232 444233 443964 380428 453886 437154 407916 428739 472500 4...

output:

24836208526
27039817629
24649395628
21466445483
24952906782
25892115705
24907499636
25355232770
26881376077
28601663089
25243897840
19941019906
19463497758
28433024337
25148214934
27792319308
26484430796
23121856258
26103744630
25998012599
23942519670
27465313979
24583294341
25763216278
26484417788
...

result:

ok 2800 numbers

Test #32:

score: 80
Accepted
time: 10162ms
memory: 20080kb

input:

500000 3500
471373 443860 495976 474838 458555 493472 483464 495255 464098 489972 486977 478599 495683 432702 461380 469926 485526 479129 463495 487275 494309 484699 493762 448478 455652 483166 482066 480424 482947 447127 492692 492277 494717 445665 492763 484453 463422 494822 476919 470749 473905 4...

output:

26908728508
31592739838
20971516201
25532277914
23142376072
30515143078
26357448174
30691796154
20723153628
20241602838
25061603335
22161107016
23131585402
29620014580
23741059192
25874130886
24162063793
29513869972
27740833763
24316078972
27522187419
28164887368
22607922670
31318242933
26393212552
...

result:

ok 3500 numbers

Test #33:

score: 80
Accepted
time: 10381ms
memory: 23884kb

input:

500000 4200
468971 436075 498100 447061 474179 433981 490896 472343 496373 486907 489901 495234 493969 479429 486558 496454 466586 481728 493556 478106 484098 480471 431829 487304 471441 495509 499672 434311 474952 422275 476017 487225 498877 471364 492388 449736 407408 496076 498270 491307 419500 4...

output:

27612981172
21794003161
25036835448
24963366497
23648962422
28818315311
29531012032
22396396480
21321463444
27489242399
22635233954
29927091378
26978903659
32126191004
26314362772
21159922614
27308930633
31995641134
22103971812
21663160885
23943086062
24762790439
24772010105
22103678886
25307494160
...

result:

ok 4200 numbers

Test #34:

score: 80
Accepted
time: 10595ms
memory: 19676kb

input:

500000 5000
473537 490921 496011 474165 481280 477775 446900 489913 469341 463697 467972 416147 481706 410570 470221 460951 452504 425164 496258 451191 475599 409884 423498 489375 473943 467326 499056 463433 374013 498151 497133 491113 470438 498833 434284 468458 383492 466233 498228 495283 461619 4...

output:

24365923919
24805653734
26648305401
26699087169
24901484273
26482770675
28374989359
24970002014
23568122059
19947940503
22244025757
22759118753
26633568499
33979018429
23413126031
24649947840
23642945008
30773710524
22428799096
33687332047
23888881393
24806152591
22029824562
32995429650
22579322859
...

result:

ok 5000 numbers

Test #35:

score: 80
Accepted
time: 10838ms
memory: 19724kb

input:

500000 6000
482222 475435 485958 386488 454475 487734 494879 475897 499219 489042 478483 465030 488578 496915 454978 495788 496003 497834 490614 464216 480311 432047 491826 369844 477300 498111 486935 496957 498599 489302 491757 486606 496817 457934 489834 488706 493559 489273 423642 443734 485680 4...

output:

28987332149
25220596414
25929439279
29340141589
21636060220
28271453772
26728766987
27187719793
20985726707
27010045738
28690092764
19352797507
18853428201
22440403514
26675694729
33864467169
29474318354
16947745571
28672115179
20360333457
21394460197
16500925138
26549765354
25191118992
24000372545
...

result:

ok 6000 numbers

Test #36:

score: 80
Accepted
time: 10975ms
memory: 19732kb

input:

500000 7000
348955 481628 492320 466286 478809 478102 475372 494947 448558 488371 480739 408077 471397 490165 463543 498799 482308 455428 493126 399385 498405 481743 497959 428139 479818 411889 467929 450560 495329 441521 443569 499127 498385 487229 499310 472841 442817 456755 457914 446532 411640 4...

output:

19891739115
26243221412
16259790012
26555279245
21928748774
28233687050
26624521959
22754105360
25581798076
29552593439
26055918942
31818986967
23050449152
26722611909
29452359076
23148630679
28791191539
23806437850
26983394951
20871921276
24455096426
21209359705
27174012930
19849454039
28274330572
...

result:

ok 7000 numbers

Test #37:

score: 80
Accepted
time: 11163ms
memory: 19920kb

input:

500000 8000
496663 464306 477960 481764 497681 493440 470860 482416 448528 439705 495015 493037 407534 489115 408970 489727 494133 474907 499946 496003 485134 480831 489971 470916 467577 477789 477004 473779 485043 422982 489664 471889 486852 474808 462240 490538 483093 489648 411758 410869 402486 4...

output:

27158969454
22611024915
17656530254
25749785997
25504622447
19539565930
23301405778
24424433048
27966019245
34191271852
20710532501
22163370030
25530656317
20508011357
24936533842
32912479973
25677497735
18589991471
25204811396
18803311477
28658643444
23884785636
23468175201
27847412806
35943637625
...

result:

ok 8000 numbers

Test #38:

score: 80
Accepted
time: 11304ms
memory: 22052kb

input:

500000 10000
442115 493523 429489 488051 497456 480947 483268 492953 438718 495816 480423 499647 494693 476607 492238 432620 433371 487052 468913 492672 396238 388605 398653 482486 452130 469408 327796 497773 483226 496374 473129 479712 498307 426271 479876 481671 480015 491858 452665 486222 460965 ...

output:

25206028222
41607063604
21786188532
25030340724
27951780529
20835382983
23876831843
24521498281
29418074413
30409004599
26219931882
22454699364
21219542015
21736165136
23344479404
16316554706
27332066191
18392597310
18638797189
15113645381
23349061307
20146247366
23908303599
23281621132
25299077710
...

result:

ok 10000 numbers

Test #39:

score: 80
Accepted
time: 11472ms
memory: 19964kb

input:

500000 11000
374018 475268 414391 498454 457201 490838 458619 417115 420220 492655 373012 453392 363040 490474 488916 366965 495395 484823 461412 420153 499398 476222 453980 488456 489894 445745 478696 448172 494827 475936 482665 498851 400744 496869 413222 428948 496552 422501 495702 474538 497166 ...

output:

21088459038
26257347034
19278768488
18143789112
19068889568
24065279995
26711483228
29364466017
31704342433
16851394773
36191740436
37008863491
19754359528
23194867175
25174862400
26197873710
32991080282
18555601991
19164638491
30455277236
20562052220
31688525954
21178940194
22121010197
18584272349
...

result:

ok 11000 numbers

Test #40:

score: 80
Accepted
time: 11527ms
memory: 19696kb

input:

500000 12000
448934 499464 487306 439168 462884 416114 468998 399335 498247 464168 456336 491725 491193 481040 490040 492572 479691 482365 455592 453944 492563 433491 426095 481330 458725 494926 497378 497962 447177 445979 480412 443222 472431 467941 324401 495756 448910 497691 492503 412730 388547 ...

output:

28649335499
14673333500
30230858064
24042670737
26808146648
18657626214
30246290464
33817764633
21718347024
19025527375
24538409263
30065983626
19606896150
26087549934
15785626082
20676032133
24356121266
26843981437
29171378214
32248740994
20920769325
34063737724
16223340945
26081892210
18218495711
...

result:

ok 12000 numbers

Test #41:

score: 80
Accepted
time: 11705ms
memory: 20128kb

input:

500000 14000
385516 496021 443062 484027 467167 454902 481385 460880 460357 495346 487763 484319 489023 497549 497418 471740 491019 481555 494974 497195 478898 357111 462444 499751 450916 498917 494763 338089 487237 498773 464246 389795 481491 486132 450156 471001 478652 476475 296935 459755 494852 ...

output:

41637470224
11746660855
21002392535
26342987894
17736580412
10849900518
17265874040
27553231127
27712816417
10580704100
24043655324
21919786398
15206687013
27052590067
13905701988
23006442522
27956650970
19850596993
24067789411
23651622553
21573919135
15140833513
18346226665
16788010599
33326428998
...

result:

ok 14000 numbers

Test #42:

score: 80
Accepted
time: 11906ms
memory: 19840kb

input:

500000 16000
495002 391983 454511 401415 460749 493266 491160 485493 488150 453249 473977 390049 465645 477894 425985 474259 437063 483790 397119 484362 435855 476841 482941 498185 495428 356722 449751 466368 487744 487960 441698 480258 469038 407187 462352 373128 443077 486731 487229 450677 494218 ...

output:

22719526460
27874657664
22873272493
27332110213
26555119508
27710747438
24950224735
17235722804
22288322019
30752573291
26533882392
31741537856
19956077869
23034235414
25884376763
16536108990
14567523159
14609773876
30016248637
11505708184
24066130705
26621292184
17890092547
24940066703
20849226062
...

result:

ok 16000 numbers

Test #43:

score: 80
Accepted
time: 12052ms
memory: 20112kb

input:

500000 18000
497576 470140 479590 422480 454720 449798 491307 499470 498879 499926 498386 389132 486717 499510 489298 433131 490198 496403 498355 492384 470348 395060 484811 494009 497373 461082 487184 438710 426775 485914 444642 449520 379613 480992 493082 482395 483512 483452 483214 495749 493514 ...

output:

25889199837
33034048421
47413653115
31262137288
10722350791
11212316048
26043915477
12598534613
27921258570
12321013151
22838625538
14041608197
42187552485
28793577920
15537019179
28945495112
27641762589
5174028811
25711851411
41132327008
35227380380
36295920086
27611257063
10411331571
20533624738
1...

result:

ok 18000 numbers

Test #44:

score: 80
Accepted
time: 12203ms
memory: 19992kb

input:

500000 20000
461581 478547 475474 442246 499026 485163 454915 482481 491071 444483 430342 477602 497891 491268 396358 444411 414825 491788 478140 432827 495216 450117 452284 487487 494004 423392 460402 363193 480896 488044 371178 499270 487334 450197 411051 435338 478994 411638 478815 498900 439117 ...

output:

31643138722
25383000164
35391182827
20015239508
17632851301
16542144874
30919248004
22418268426
21589033332
13802526774
15822032131
43965237497
17224148895
26707561238
11977436537
29764046690
25598753733
24997002694
20937299515
25277199941
9632086035
20341377331
29722632724
19761233018
19115274076
1...

result:

ok 20000 numbers

Test #45:

score: 80
Accepted
time: 12296ms
memory: 21800kb

input:

500000 25000
466385 489900 424097 382582 456270 496672 476989 490388 493171 480298 489824 484319 452880 497820 474812 456517 477623 499467 444167 452288 484193 465930 469095 473225 465281 475396 433893 479326 446635 491744 498100 447910 408605 447136 486727 404157 404588 496506 447951 488549 451425 ...

output:

12098270062
27525258795
36284121927
42403397532
27483150736
12965160788
10179153230
13483799304
21234910455
21115969727
24597142765
15795414256
30771866555
35559500101
26643893122
24081321973
45019091616
30290195255
30395516399
22107673194
21916696135
39981386425
19320353152
857131853
16694873906
30...

result:

ok 25000 numbers

Test #46:

score: 80
Accepted
time: 12581ms
memory: 19916kb

input:

500000 30000
489299 476291 449530 490633 481712 484491 466489 499477 415883 486431 492286 491589 476905 487345 460809 464288 478549 495864 480306 397951 478501 492760 478060 386827 460544 445630 421680 461291 399768 434641 406068 441658 496951 424665 423764 492578 463983 473445 486123 434274 414775 ...

output:

25197465606
20824583375
16386520700
17572829839
20647859881
27928253263
28520248068
29627970440
25776131129
17857720918
20513042894
26357798612
15744070299
21672709837
21372474402
30508086454
39713382526
21731962690
18861938055
25742411040
23723112405
28833405737
9623019624
33670119896
16331215140
2...

result:

ok 30000 numbers

Test #47:

score: 80
Accepted
time: 12682ms
memory: 20032kb

input:

500000 40000
498639 481652 439996 496532 472411 491589 363886 458892 493538 499638 499890 486275 384664 475715 483239 483361 496231 495501 485611 489940 440554 492559 484767 485923 445389 491215 497214 476400 479038 499641 499923 477635 499339 430528 476716 432769 479870 480112 369508 493094 414605 ...

output:

34795560920
24969704766
7678900412
13312231795
23719933608
15935327402
11165662559
0
33191774327
26907215348
32186120484
19870335533
22655213978
28358521467
26823145255
15778867759
22189460809
13281780598
27768423153
13803934544
16535068518
15910078804
30059738295
34893656715
30725730445
21214327323...

result:

ok 40000 numbers

Test #48:

score: 80
Accepted
time: 13093ms
memory: 22100kb

input:

500000 60000
497711 493715 422258 490464 489239 422075 488233 481685 488249 482563 481886 496619 492354 483982 461819 338536 477687 471235 496679 470765 381507 483293 434644 436057 492761 463474 499654 435565 486810 488151 461658 486080 459504 422880 497153 491737 498083 483971 475982 494734 486408 ...

output:

11270358298
24345718212
11050766546
13136311759
47361925693
38350948682
14604532178
14948150295
2750521125
29080046117
5156339677
39328300304
25094350448
31035099564
44378579102
43378118400
15411100272
10366960109
3549336583
20130075464
5613404834
3351035534
35910570019
17937630540
18951154270
24949...

result:

ok 60000 numbers

Test #49:

score: 80
Accepted
time: 13412ms
memory: 20912kb

input:

500000 80000
455960 465167 489249 493000 442337 490362 432344 491498 479761 482560 470754 487105 388846 488651 492992 470161 375819 430044 449047 385887 372361 457617 491997 474138 495768 446077 390480 475566 496693 482099 487298 381337 451940 464910 421745 486415 484212 488609 483087 488439 488220 ...

output:

16868877119
769121254
28633020354
0
6327357586
29122706141
11204461252
39557190481
30141035121
606624000
18547117819
21832836351
15242179244
14951914870
37990954508
38642557088
33520970526
6071585997
23961520973
24085425362
28238766249
7371725319
16383922117
21385480157
31780812113
8413021966
102980...

result:

ok 80000 numbers

Test #50:

score: 80
Accepted
time: 13678ms
memory: 20536kb

input:

500000 120000
494597 451588 486171 342661 475427 448751 488906 478568 481190 448236 480692 473396 433370 490927 456751 480091 453002 452020 386136 497396 412253 438851 457230 480761 428403 493942 456305 495808 483779 495616 483185 499206 472647 489622 490347 391795 476445 499082 449027 497074 472709...

output:

2670779952
5052010437
18431200686
9627891133
26768651098
27174027582
12012606671
6705492539
30204881948
11801258081
10053533818
0
720207598
25812300755
2275038895
1749972024
29416304944
8198673581
25627613469
8695276381
1350131837
16566621139
20622368211
10736268551
5764371870
0
2925395143
102714488...

result:

ok 120000 numbers