QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#411514#8683. Bridging the GapCrysflyAC ✓132ms434460kbC++171.7kb2024-05-15 15:19:282024-05-15 15:19:29

Judging History

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

  • [2024-05-15 15:19:29]
  • 评测
  • 测评结果:AC
  • 用时:132ms
  • 内存:434460kb
  • [2024-05-15 15:19:28]
  • 提交

answer

// what is matter? never mind. 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2") 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define int long long
#define ull unsigned long long
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
 
#define maxn 10005
#define inf 0x3f3f3f3f3f3f3f3f

int n,c,a[maxn],up;
int sum[maxn];

int w(int j,int i){
	return sum[j]+a[i];
}
int f[10005][10005];

signed main()
{
	n=read(),c=read();
	For(i,1,n)a[i]=read();
	sort(a+1,a+n+1);
	if(n<=c)cout<<a[n],exit(0);
	
	For(i,1,n)sum[i]=sum[i-1]+a[i];
	up=n/c;
	For(i,0,n)For(j,0,up)f[i][j]=inf;
	
	f[0][0]=0;
	For(i,1,n){
//		cout<<"i: "<<i<<"\n";
		if(i<=c) f[i][0]=min(f[i][0],w(0,i));
		For(j,0,(n-i)/c+1){
			For(k,0,j+1){
				if(k>c) break;
				// 1....i   -> j<-
				if(i>=c+1 && i-(c-k)>=0 && k<c)
					f[i][j]=min(f[i][j],w(k,i)+f[i-(c-k)][j-(k-1)]);
				// 1..k  + (l..i) --> , 1...k <--
				if(i<=c && k>=1 && k<=c)
					f[i][j]=min(f[i][j],w(k,i)+f[k][j-(k-1)]);
				// 1..i -->, 1..k <--- , 1..k -->
				
			}
		}
		
//		For(j,0,up){
//			cout<<f[i][j]<<" ";
//		}cout<<"\n";
		
	}
	cout<<f[n][0];
	return 0;
}
/*
4 2
1 2 5 10
7 2
1 2 4 5 7 10 14
7 3
2 2 2 3 6 6 6
*/

详细

Test #1:

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

input:

2 10000
287416173 56224986

output:

287416173

result:

ok single line: '287416173'

Test #2:

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

input:

10 10
1 1 1 1 1 1 1 1 1 1

output:

1

result:

ok single line: '1'

Test #3:

score: 0
Accepted
time: 132ms
memory: 434460kb

input:

10000 2
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000...

output:

19997000000000

result:

ok single line: '19997000000000'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3536kb

input:

4 4
18 17 5 14

output:

18

result:

ok single line: '18'

Test #5:

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

input:

8 7
5 9 12 13 4 3 11 12

output:

20

result:

ok single line: '20'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

2 2
19 17

output:

19

result:

ok single line: '19'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3676kb

input:

9 2
8 8 11 14 18 7 13 15 16

output:

138

result:

ok single line: '138'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

8 9
9 11 17 11 14 4 4 15

output:

17

result:

ok single line: '17'

Test #9:

score: 0
Accepted
time: 123ms
memory: 434396kb

input:

10000 2
665202753 897548912 921986560 575751403 770785130 287154554 19816812 765069479 226216894 974656500 12997764 875561825 889646889 138359029 415852338 324049168 412235599 944033425 285634471 595710363 351373309 536003659 971497658 457447650 304556948 628141292 106332191 808632701 617513243 6598...

output:

2517813461584

result:

ok single line: '2517813461584'

Test #10:

score: 0
Accepted
time: 115ms
memory: 304156kb

input:

10000 3
621175067 917101939 23097829 867157751 618714840 664252905 160013543 698818638 561469183 199904266 202096412 603292580 613796714 169816069 769518744 92280972 50335186 943993051 559623274 806945681 450915831 945500817 208042581 484070368 936105894 90987054 600108436 180516526 449242509 489767...

output:

1671657183071

result:

ok single line: '1671657183071'

Test #11:

score: 0
Accepted
time: 84ms
memory: 239020kb

input:

10000 4
846960764 612579079 952635701 825950264 467208348 289351760 838498523 582201032 963697689 537677317 325278072 809362753 393327712 899454456 396952332 618518702 53017002 836653788 81590462 844685031 415510473 843055176 357708840 395511647 947231018 176450106 417709878 744274135 931182253 5171...

output:

1253446906215

result:

ok single line: '1253446906215'

Test #12:

score: 0
Accepted
time: 78ms
memory: 200000kb

input:

10000 5
852347250 771154746 168829536 135598534 877032534 380414913 472859697 239240027 728238930 354865588 887464232 499887407 54298465 276917871 369599187 584677996 217383012 9366472 688771631 917345185 198293297 927320074 73081786 536543433 793117410 989064181 47823477 389570878 506884191 2421035...

output:

1001130037181

result:

ok single line: '1001130037181'

Test #13:

score: 0
Accepted
time: 69ms
memory: 141396kb

input:

10000 8
642134259 129742757 429228464 648290582 10691460 4170069 774168759 596483622 913088968 658064532 972647017 667039052 101527833 394743052 108795899 709398987 681688264 710822127 44191064 947034250 468179140 585105201 4544091 508175143 102493845 895316723 211235108 121753860 461894941 14523822...

output:

619950568582

result:

ok single line: '619950568582'

Test #14:

score: 0
Accepted
time: 68ms
memory: 130532kb

input:

10000 9
546374465 387744952 561155381 591828110 685682223 672283368 164921935 669750835 301071560 330136223 249413332 41338945 742551535 381574115 107267518 355551296 156089783 53995705 273922987 739180152 453703767 941152055 657051323 310256019 134098432 438713919 599903167 783464129 149737306 7395...

output:

559319535334

result:

ok single line: '559319535334'

Test #15:

score: 0
Accepted
time: 66ms
memory: 68096kb

input:

10000 32
171869672 55094924 617215304 568208303 893438943 330699402 967037867 226783858 486783437 929420101 213418932 281667034 19213740 12138622 857929009 185172501 835861521 780336155 280964480 844938882 56007204 225592086 799378695 539584187 606095119 892199957 17486474 220188023 31834148 2180605...

output:

156063937897

result:

ok single line: '156063937897'

Test #16:

score: 0
Accepted
time: 63ms
memory: 62224kb

input:

10000 42
931430709 729947666 54872535 113528222 800655897 911469120 94074364 950382034 93197301 112265983 451597370 571090604 803618609 916439429 135708791 313718225 861931146 716489047 274940908 916280562 719573912 546041907 499365934 572075226 239281532 995852185 348895918 112198544 779086866 2046...

output:

119877106702

result:

ok single line: '119877106702'

Test #17:

score: 0
Accepted
time: 11ms
memory: 47496kb

input:

10000 204
5709440 505191231 4022059 119024679 925100433 194674868 431665664 210777577 367950841 367871280 256689417 314592593 816197315 434383843 217427376 97834891 133242215 635957953 832626592 120918674 793561574 306075350 952346870 101031523 581508053 538509875 32262047 885323499 611292896 980426...

output:

24914341623

result:

ok single line: '24914341623'

Test #18:

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

input:

10000 9981
80448836 213070612 877175445 949528228 439352416 218046657 620144172 721129486 480541877 909055929 961320997 390034301 855874883 28224320 453569286 561956387 571284382 282480530 705412395 575250864 414329551 792515861 787361147 534486347 717273126 73786461 904494071 169911634 234514514 25...

output:

1001600862

result:

ok single line: '1001600862'

Test #19:

score: 0
Accepted
time: 111ms
memory: 426772kb

input:

9906 2
31030352 495767073 938388358 31806217 603944627 711349621 107168971 741419732 577831153 644462245 613629849 381484836 516151716 693339835 768110741 474532647 919007099 740519111 508105124 61185052 372708522 966609688 637573594 734090240 60012042 803262271 922910251 810124588 44824292 51369586...

output:

2484862627122

result:

ok single line: '2484862627122'

Test #20:

score: 0
Accepted
time: 88ms
memory: 303872kb

input:

9994 3
218875034 379003769 324140588 537809096 560254492 519798744 435289962 648905089 631255159 289127056 346121879 201907552 730452765 810159748 547816967 914254282 221228118 945285369 21787397 998318374 650480596 264178937 555136291 354687431 528940218 603257375 623873549 604305985 987485289 9371...

output:

1669343942727

result:

ok single line: '1669343942727'

Test #21:

score: 0
Accepted
time: 70ms
memory: 238380kb

input:

9984 4
358094888 329272830 700366461 682976534 148577413 521744950 739424309 167432195 520600477 401634443 281932177 33367889 735688407 869166633 737052581 702749027 144584544 56158696 151406136 549610621 807473377 848570624 548623130 864873605 584281645 863699992 872453372 653894774 195141933 37387...

output:

1259869094596

result:

ok single line: '1259869094596'

Test #22:

score: 0
Accepted
time: 82ms
memory: 197752kb

input:

9935 5
843447686 495953743 599835015 554867169 972093474 973351153 613197708 317336591 306271246 211861356 768734356 169663690 592887139 958189385 804114209 403073945 787351775 140754037 253309841 606186802 555541335 267500719 511628653 387614869 971988816 588890651 514211425 938299201 979116479 712...

output:

997228738948

result:

ok single line: '997228738948'

Test #23:

score: 0
Accepted
time: 73ms
memory: 171448kb

input:

9918 6
670985278 531160590 590372036 575905820 366968227 893523324 30610627 81760999 242376775 376104206 490627555 397296676 997936393 748955170 815043448 196909540 364254808 96958931 753475316 873445337 130975282 701264634 621502730 722161449 19191648 766545955 892917883 68967507 509881950 73822395...

output:

832970953301

result:

ok single line: '832970953301'

Test #24:

score: 0
Accepted
time: 59ms
memory: 120108kb

input:

9910 10
715688039 137137063 825786485 273910205 12022274 963919110 797365602 458917989 635380226 82278807 452637670 987041802 977036144 591550758 575333712 684562650 261275327 394616273 771043072 707446757 646222170 824508784 434709039 457261709 190602493 207080812 646804299 678404344 517924261 2801...

output:

494404725970

result:

ok single line: '494404725970'

Test #25:

score: 0
Accepted
time: 67ms
memory: 63524kb

input:

9903 38
110417798 355310955 297322465 124857368 4762299 192177993 418072765 387739746 300177948 461668186 460855039 17612691 103218734 133955049 479805308 88175302 581605611 173453176 771134602 956653420 581736134 561557220 360665006 111179833 819788884 374175207 925832806 576356435 837392295 734664...

output:

130404908805

result:

ok single line: '130404908805'

Test #26:

score: 0
Accepted
time: 69ms
memory: 64024kb

input:

9988 38
168649132 705636968 769891174 800477046 494169423 444610761 367292272 456480524 293315817 881504369 670199417 975913664 225622395 178100657 735012041 620208517 867440250 906323336 580670417 285183332 6672081 879003325 716964663 561396619 28214251 73842135 593105931 851815849 648355509 331989...

output:

132195931737

result:

ok single line: '132195931737'

Test #27:

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

input:

9947 634
593677451 336933756 921386273 909912000 752900522 667926417 636283191 933128155 416448842 941863301 136907264 383697189 561021505 575448939 926581824 819094385 10890716 684437763 331361196 862438641 442572784 833242937 617537575 139607005 955338041 395120425 101467938 228978865 210054065 80...

output:

8390947408

result:

ok single line: '8390947408'

Test #28:

score: 0
Accepted
time: 0ms
memory: 43696kb

input:

9989 5259
608885681 985204306 957728012 272892819 321102306 778329984 597580749 772420697 184051728 85222452 683794245 294428508 458165962 741838092 573234379 952856069 208847057 324246051 235264919 63389415 212359886 388169901 119253371 45944056 124335273 34358254 291056590 144319824 128300538 3724...

output:

1470689964

result:

ok single line: '1470689964'

Test #29:

score: 0
Accepted
time: 128ms
memory: 431332kb

input:

9962 2
56 167 66 222 244971238 4609131 47519775 1782 7172912 1157579 54011 19056758 7819 22 37 303 48156175 372407 403408625 174598693 12177 120227 43119950 362596 502 378904028 11 3464 315391 9985 744 573012320 11 6510896 16 40142 4319260 10359 2598463 17243983 14 82 1056 12630958 508920255 4451261...

output:

275721685736

result:

ok single line: '275721685736'

Test #30:

score: 0
Accepted
time: 91ms
memory: 303708kb

input:

9991 3
13 33080 129772 10037 445617 763063 116949924 18113098 17932193 1163 8805 21437 19389500 34 1205245 22247 133497050 186085145 100 308 2732 13809 3208 22 35 123 20326 28631171 17685794 213235 23584866 8239830 33 5160 353402 821498 285 819 11976683 63992 701 164 14486 8823 718197389 10532698 19...

output:

176215435504

result:

ok single line: '176215435504'

Test #31:

score: 0
Accepted
time: 80ms
memory: 238572kb

input:

9988 4
3996 15887054 381135 100270706 114226626 5194239 745901004 36 3580493 14007898 187651 1222 236 1729 33399 3081239 37852740 154 398 495 249734 10963 677393584 3530 1426 336 74022857 30226 35 1102275 23 235 1599 36717798 3885 603108232 514 33250193 346 27975185 10 42015802 179956 142 18 441228 ...

output:

135264135102

result:

ok single line: '135264135102'

Test #32:

score: 0
Accepted
time: 70ms
memory: 198892kb

input:

9969 5
57128 36 44 295274275 15394 2845787 167687 1873 549998 41 3565427 87511 128 31 5172 7548 340 1677 149528982 870 47 649054254 162 9327703 2281 59 6189410 36246 89 10 89675 334076443 79 618 131 65566 698 480603487 79645 1072 241324 141396687 281 24758 279 337816 17 17 1435 96062449 25 11 626446...

output:

105565960510

result:

ok single line: '105565960510'

Test #33:

score: 0
Accepted
time: 61ms
memory: 173016kb

input:

9967 6
119628 5180 516 111 1931974 647 3196830 495821 5202 305720 67067 51014 25 92415198 45 8155 333 472659195 18 25502585 1519796 58331 1421782 267049950 7603 116134286 18446 31160482 235 1272284 4152062 117 342411712 5680 9201061 13 3778 1532947 5980 72 6487772 405506509 4004 603003809 987 875 13...

output:

92956836604

result:

ok single line: '92956836604'

Test #34:

score: 0
Accepted
time: 69ms
memory: 171968kb

input:

9938 6
246347 12946 5083 53 65098 92 29467 264890 35711 270 3178234 41507 374726108 5300127 137060 9811 16465399 377428 101192067 367686803 12367 2247486 901696429 128181917 338545 39 12798 528835607 64602 450 13622 571009590 8920428 2156708 52173061 262946686 670 119 162 2418 21 54 32821 8214632 16...

output:

88344783630

result:

ok single line: '88344783630'

Test #35:

score: 0
Accepted
time: 54ms
memory: 56240kb

input:

9955 61
321 4955 475701 39929501 236090 9077776 138046827 91269440 737 1914560 381818715 2122126 25016315 1709412 210570437 15785655 581 1169 480356046 186902 9057285 345874 400264816 2235 322553475 103765 83362527 665 3108 22 3961 44366586 117388685 418 241809773 4208563 3643797 784360 1126297 1606...

output:

9662406627

result:

ok single line: '9662406627'

Test #36:

score: 0
Accepted
time: 56ms
memory: 54556kb

input:

9997 72
523497 263494 38172714 16365038 11140780 4142 671290168 13660756 607 13 464898827 4551368 36320849 11686025 446 11 75467 10627636 253 646542 3355 487 57290 13500 4965 2026 165 101511129 26830567 5857342 150315 416 14851 93693 165 463 955618212 613163092 107365 8094002 92 605537999 1799 72925...

output:

8213002130

result:

ok single line: '8213002130'

Test #37:

score: 0
Accepted
time: 8ms
memory: 46840kb

input:

9909 219
224385 4777199 14314002 70592073 4648243 195936523 182 4164 587 25 2870 644116 3505 133 396 14613 512808561 447 454778 14025368 145358 202767453 87687925 6690 10469048 24 2391 7204733 233102 149454 26 4638 262 37770 997 64 24 502483812 112889708 11 874793 4824987 134507919 3255198 249451 43...

output:

3023350352

result:

ok single line: '3023350352'

Test #38:

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

input:

9962 1985
11 262497 1890 27 52885028 182 53926 1547917 43524842 73582 41239 896 3715184 8453419 102985204 352773134 578537 108 1316 187 484576 224 325 28205 2409851 72539896 20883 295 12902 184 128765 221537833 48 4507 182906 456113 1530193 58496324 206 256745789 341 25564 169645 873 26631466 22 554...

output:

1024493722

result:

ok single line: '1024493722'

Test #39:

score: 0
Accepted
time: 115ms
memory: 433308kb

input:

9986 2
1000000000 1 1 1000000000 1 1 1 1 1000000000 1 1 1 1 1000000000 1 1 1000000000 1000000000 1000000000 1 1 1 1 1 1000000000 1 1000000000 1 1000000000 1 1 1000000000 1000000000 1000000000 1000000000 1 1000000000 1000000000 1 1000000000 1 1 1000000000 1 1000000000 1000000000 1000000000 1000000000...

output:

2512000017457

result:

ok single line: '2512000017457'

Test #40:

score: 0
Accepted
time: 94ms
memory: 303880kb

input:

9997 3
1 1000000000 1 1 1 1000000000 1 1 1 1000000000 1000000000 1000000000 1 1000000000 1 1000000000 1 1 1 1 1000000000 1000000000 1 1000000000 1 1 1 1000000000 1 1000000000 1000000000 1 1000000000 1 1 1 1 1 1 1000000000 1 1 1000000000 1 1000000000 1 1000000000 1000000000 1000000000 1 1 1000000000 ...

output:

1656000008339

result:

ok single line: '1656000008339'

Test #41:

score: 0
Accepted
time: 80ms
memory: 199804kb

input:

9995 5
1000000000 1 1000000000 1000000000 1000000000 1 1000000000 1000000000 1000000000 1000000000 1 1 1 1 1 1000000000 1000000000 1 1 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1 1 1 1000000000 1000000000 1 1 1000000000 1000000000 1 1000000000 1 1 1000000000 100000...

output:

1007000003990

result:

ok single line: '1007000003990'

Test #42:

score: 0
Accepted
time: 62ms
memory: 86856kb

input:

9983 18
1000000000 1 1000000000 1 1000000000 1 1 1 1000000000 1000000000 1 1000000000 1000000000 1 1 1 1000000000 1 1 1000000000 1 1 1 1 1000000000 1000000000 1 1 1000000000 1000000000 1 1000000000 1000000000 1 1000000000 1 1000000000 1000000000 1000000000 1 1000000000 1000000000 1000000000 1 100000...

output:

278000000897

result:

ok single line: '278000000897'

Test #43:

score: 0
Accepted
time: 0ms
memory: 45636kb

input:

9965 370
1 1 1000000000 1 1000000000 1000000000 1 1 1 1 1 1000000000 1 1000000000 1000000000 1 1 1 1 1 1000000000 1 1000000000 1000000000 1 1 1 1 1000000000 1000000000 1 1000000000 1 1000000000 1 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1 1 1 1 1000000000 1 1 1 1000000000 1 ...

output:

14000000041

result:

ok single line: '14000000041'

Test #44:

score: 0
Accepted
time: 0ms
memory: 43732kb

input:

9971 5878
1000000000 1000000000 1 1000000000 1000000000 1 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1 1 1000000000 1000000000 1 1000000000 1000000000 1 1 1000000000 1000000000 1000000000 1 1000000000 1000000000 1 1 1 1 1 1 1 1 1000000000 1 1 1000000000 1 1000000000...

output:

1000000002

result:

ok single line: '1000000002'

Test #45:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

10 4
1 2 100 99 98 97 96 95 10 9

output:

208

result:

ok single line: '208'

Test #46:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

10 4
1 2 100 99 98 97 96 95 9 8

output:

208

result:

ok single line: '208'

Test #47:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

10 4
1 2 100 99 98 97 96 95 8 7

output:

207

result:

ok single line: '207'

Test #48:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

15 6
1 2 1000 990 980 970 960 950 940 930 920 910 900 890 880

output:

2830

result:

ok single line: '2830'

Test #49:

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

input:

15 6
1 2 100 99 98 97 96 95 94 93 92 91 90 89 88

output:

287

result:

ok single line: '287'

Test #50:

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

input:

12 3
8 9 9 6 9 9 10 8 8 3 4 5

output:

59

result:

ok single line: '59'

Test #51:

score: 0
Accepted
time: 7ms
memory: 47576kb

input:

10000 200
16808 282475250 622650074 984943659 144108931 470211273 101027545 457850879 458777924 7237710 823564441 115438166 784484493 74243043 114807988 137522504 441282328 16531730 823378841 143542613 896544304 474833170 264817710 998097158 817129561 131570934 197493100 404280279 893351817 50579533...

output:

23679249082

result:

ok single line: '23679249082'

Test #52:

score: 0
Accepted
time: 36ms
memory: 50972kb

input:

9899 100
976728860 203422613 307150563 934141825 210516304 499056530 487491789 652143128 374809049 278649467 805113173 252201361 232714147 363402991 207812947 516305665 256447113 628636176 509389185 396545142 393822662 716058909 785075296 345912160 186380505 898774592 738127653 564758804 836386286 9...

output:

54349601014

result:

ok single line: '54349601014'

Test #53:

score: 0
Accepted
time: 39ms
memory: 51012kb

input:

9901 100
914000000 997000000 907000000 924000000 937000000 981000000 907000000 907000000 961000000 974000000 964000000 954000000 904000000 929000000 971000000 921000000 931000000 984000000 930000000 949000000 950000000 905000000 975000000 1000000000 953000000 968000000 937000000 960000000 904000000 ...

output:

93248025046

result:

ok single line: '93248025046'

Test #54:

score: 0
Accepted
time: 55ms
memory: 53700kb

input:

10000 78
37 69 78 45 99 73 8 6 73 75 72 29 33 75 90 4 96 69 94 65 24 41 3 9 21 60 81 93 25 46 13 77 17 84 72 76 66 82 62 28 38 93 43 88 1 3 48 24 53 72 96 44 68 93 75 61 47 60 7 42 57 24 54 79 62 52 69 69 37 29 36 70 63 93 95 97 63 6 19 68 71 40 5 31 84 45 86 59 80 36 51 16 65 28 61 37 13 61 31 42 1...

output:

6560

result:

ok single line: '6560'

Test #55:

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

input:

10000 896
42 25 10 68 36 43 26 50 25 71 89 72 5 70 6 74 65 36 60 71 34 38 57 54 28 16 78 12 72 68 71 29 41 24 25 57 56 29 85 19 41 1 29 23 80 38 96 54 90 3 97 22 66 71 27 10 34 87 3 83 62 3 74 77 96 29 86 77 37 7 48 16 21 75 94 1 38 95 63 19 73 81 8 39 47 9 22 86 86 46 21 18 67 40 3 73 50 47 73 87 5...

output:

618

result:

ok single line: '618'

Test #56:

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

input:

10000 6161
66 8 74 50 92 10 55 31 28 13 21 39 8 48 83 47 66 44 59 71 10 3 73 59 30 43 38 59 53 66 38 30 66 85 43 67 65 82 71 10 72 80 88 91 96 39 69 91 58 6 49 12 6 90 72 86 34 18 17 35 68 54 63 77 66 62 70 19 36 12 98 13 25 39 25 69 22 31 18 31 73 66 41 77 21 7 80 12 46 50 6 15 30 93 42 42 6 61 28 ...

output:

139

result:

ok single line: '139'

Test #57:

score: 0
Accepted
time: 56ms
memory: 57068kb

input:

10000 58
59 93 77 84 46 89 13 12 33 10 49 39 64 36 52 93 26 74 82 95 5 82 51 18 93 30 43 83 70 83 19 15 29 70 30 90 46 94 90 46 18 91 71 75 29 4 78 28 30 54 11 71 7 49 52 87 76 37 31 11 16 10 89 93 55 5 44 76 8 34 96 6 81 20 11 34 62 9 32 77 87 46 14 99 82 42 56 78 61 16 52 77 74 41 12 72 60 94 77 9...

output:

8848

result:

ok single line: '8848'

Test #58:

score: 0
Accepted
time: 12ms
memory: 47100kb

input:

10000 232
44 24 31 4 45 12 81 74 75 7 58 49 20 78 69 52 75 25 91 7 60 44 82 28 91 95 40 78 21 13 15 80 61 52 47 4 38 10 75 77 93 13 51 3 76 39 17 41 43 89 58 60 59 47 23 13 47 77 96 45 46 90 85 4 86 93 6 24 95 57 65 69 80 63 9 55 55 45 44 16 64 9 59 68 2 10 35 32 33 75 77 57 95 78 30 5 35 81 63 45 2...

output:

2248

result:

ok single line: '2248'

Test #59:

score: 0
Accepted
time: 7ms
memory: 43964kb

input:

10000 3883
56 30 25 74 11 32 31 3 81 9 61 61 66 10 3 28 46 1 13 36 40 78 66 87 32 71 47 12 50 51 88 89 60 42 5 70 86 83 90 77 50 27 6 93 32 85 44 36 37 18 48 33 54 58 15 83 36 28 95 50 77 72 14 1 11 15 19 13 6 60 1 14 24 16 15 57 74 88 97 32 11 94 41 2 97 71 31 62 30 75 95 86 11 84 16 2 8 43 57 17 6...

output:

185

result:

ok single line: '185'

Test #60:

score: 0
Accepted
time: 68ms
memory: 155304kb

input:

10000 7
451744278 232549172 541052673 21635104 659774702 977855106 301702402 214549147 444457855 513798022 921432456 362794634 441174631 52100535 945793482 510068287 536380604 129638577 230973099 167907322 659279691 890114250 380875689 308942047 608422077 125079998 191619164 468311311 983285787 8417...

output:

717240491428

result:

ok single line: '717240491428'

Test #61:

score: 0
Accepted
time: 6ms
memory: 45432kb

input:

10000 418
706274893 554714021 864825276 665785354 4230122 182749577 161051063 622880726 135986282 489623852 435070119 830136794 531891372 493916173 288676795 83197475 821919216 560468947 423094055 373930568 152572730 425335306 288950255 706898889 970597628 190845443 692900766 643084757 787262460 966...

output:

12501349863

result:

ok single line: '12501349863'

Test #62:

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

input:

10000 1765
186943402 864718368 250205954 856902554 158063397 159858875 947704821 913978306 172742573 437415808 620329099 604939653 477418488 375053301 514870317 935087661 810147562 753595496 233421392 807611324 772156810 816975881 67888556 492584302 425979493 168116390 64115578 479834911 594765425 8...

output:

3377917163

result:

ok single line: '3377917163'

Test #63:

score: 0
Accepted
time: 72ms
memory: 199984kb

input:

10000 5
154128141 868617058 290324292 49393043 60034863 576690895 361365388 222921579 579717151 141292845 354140544 797206965 161479824 847562413 720073212 846936365 276768003 434217817 765654073 203334803 309307930 632549521 621445296 862045475 485579055 737426947 711730628 156509225 879768477 4619...

output:

1001165093635

result:

ok single line: '1001165093635'

Test #64:

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

input:

10000 829
664097990 89557316 888778895 497616635 605368117 378279886 271081348 56565127 779157258 917667073 522374499 20118691 795713470 101737855 277707678 217816150 503534418 985594710 917025319 712855908 53087203 943199756 177784205 833902620 473432360 894795448 291578599 392232039 298399774 9028...

output:

6532037196

result:

ok single line: '6532037196'

Test #65:

score: 0
Accepted
time: 0ms
memory: 43788kb

input:

10000 5118
886028756 542810572 390077807 382049324 834044617 260323757 677488815 983601664 964458624 935046084 376983669 900746696 711720658 547765456 962804348 348376186 271205088 883993008 888206653 380262250 19947344 492281043 321558459 138555774 598908633 838111136 345209512 438190283 488061406 ...

output:

1489184763

result:

ok single line: '1489184763'

Test #66:

score: 0
Accepted
time: 0ms
memory: 31064kb

input:

6761 952
56 22 9 5 49 7 18 92 79 91 42 9 14 26 63 24 66 20 48 67 22 10 37 24 70 96 62 43 77 18 12 93 27 89 45 49 34 24 93 9 51 39 85 13 13 20 13 8 91 51 37 98 98 18 23 60 23 19 74 70 28 58 81 92 4 98 11 45 60 63 34 12 74 73 63 42 4 93 43 14 59 97 75 89 81 76 96 80 83 23 87 12 86 70 5 52 5 61 88 38 7...

output:

414

result:

ok single line: '414'

Test #67:

score: 0
Accepted
time: 0ms
memory: 32104kb

input:

7072 5534
18 85 40 86 51 54 62 4 1 39 2 69 18 54 61 78 36 28 33 7 4 94 84 1 50 82 66 89 32 34 71 38 77 70 38 66 51 25 22 87 40 62 70 6 87 58 46 94 71 75 56 23 8 86 37 9 52 54 74 91 23 10 33 59 81 61 48 68 28 67 46 36 19 71 31 10 62 69 59 11 34 67 28 17 54 98 44 30 31 56 72 59 74 85 4 50 61 2 4 60 55...

output:

122

result:

ok single line: '122'

Test #68:

score: 0
Accepted
time: 0ms
memory: 13168kb

input:

2339 302
80 27 84 16 10 37 35 41 8 39 16 36 58 45 62 72 85 37 23 31 35 91 39 20 47 99 73 38 66 43 44 99 27 96 9 99 41 43 35 39 48 60 50 81 89 72 20 92 94 86 74 1 97 9 21 93 61 33 52 50 87 25 5 95 45 2 46 12 93 54 73 85 91 64 40 33 75 26 47 32 68 68 99 21 35 85 95 96 3 25 19 45 53 6 96 9 3 42 78 67 1...

output:

443

result:

ok single line: '443'

Test #69:

score: 0
Accepted
time: 0ms
memory: 19752kb

input:

4001 2197
83 58 60 39 76 59 45 55 11 43 67 41 86 97 89 72 79 69 99 22 79 98 12 34 13 41 12 18 48 69 18 34 28 7 55 77 30 89 44 74 95 98 83 38 23 72 33 50 84 75 43 91 50 18 26 96 32 79 77 20 4 79 69 81 29 50 12 12 12 67 20 12 96 79 37 39 92 1 66 17 16 40 50 96 64 20 62 91 15 44 53 93 1 61 77 14 43 87 ...

output:

146

result:

ok single line: '146'

Test #70:

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

input:

6452 334
955740639 990293021 294491831 638516637 836477687 567643890 998485126 803402474 391812752 217692176 326509214 654956439 607596106 159923511 813826531 194229224 614927848 737296344 664449394 34091525 133897244 270001188 805868995 291606411 892508338 521500406 219705763 878660146 846888912 50...

output:

10049492798

result:

ok single line: '10049492798'

Test #71:

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

input:

9487 5540
465010735 165537839 261167684 116660867 363081543 627752486 287093224 213684827 444468638 720611775 117942387 498620129 926794889 343344052 974003954 433606796 32839994 681172410 333601496 762248115 382237793 721593050 170578510 336615681 512332311 916412418 69580238 987676595 109009295 46...

output:

1421296080

result:

ok single line: '1421296080'

Test #72:

score: 0
Accepted
time: 0ms
memory: 15636kb

input:

2905 151
449535545 393388408 394944589 900653037 111785537 580731482 484457071 321314860 70338254 405527170 481754540 802603717 374800311 860988840 790090159 130674474 735362017 380461811 162119437 638472157 859404244 396311087 780141540 640029956 113213021 300207019 269132898 4711087 636834690 3742...

output:

10105253137

result:

ok single line: '10105253137'

Test #73:

score: 0
Accepted
time: 7ms
memory: 18712kb

input:

3759 3644
244295038 677256603 50636620 405020506 736137829 885615653 984163649 183722937 881870040 891702277 28390527 942952909 195527603 994900515 512834698 567450655 381222815 136063250 525442206 322030694 802197713 801957266 291940615 405257350 52668003 954416942 517948607 381955977 934499900 784...

output:

1036437891

result:

ok single line: '1036437891'

Test #74:

score: 0
Accepted
time: 0ms
memory: 5416kb

input:

416 13
85 52 51 86 11 10 67 50 21 31 10 76 96 84 50 4 12 17 93 74 65 43 18 47 16 45 21 39 35 97 75 3 69 83 25 81 64 90 8 62 36 19 76 12 20 84 92 84 83 97 33 36 28 23 32 57 52 1 1 35 23 72 85 91 63 6 92 97 50 36 92 85 96 72 42 4 65 92 92 98 15 12 65 87 62 23 81 69 58 20 8 34 26 61 34 22 35 82 35 73 5...

output:

1663

result:

ok single line: '1663'

Test #75:

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

input:

752 698
61 11 92 57 31 40 47 3 24 87 90 86 12 6 75 99 37 84 73 74 52 81 55 26 34 58 40 64 67 8 29 95 12 40 76 23 80 72 77 19 27 13 69 78 34 1 91 91 33 94 70 1 37 23 29 82 74 82 41 30 72 99 10 28 76 66 57 88 41 58 36 41 31 25 83 7 22 75 29 41 43 86 38 86 63 84 92 12 86 37 52 38 32 55 36 87 39 76 13 4...

output:

109

result:

ok single line: '109'

Test #76:

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

input:

234 57
24 96 6 21 30 23 8 26 68 42 23 31 41 57 73 83 57 26 13 57 59 42 83 18 54 84 34 58 62 14 23 93 63 48 81 61 50 14 89 20 85 57 40 23 67 23 59 42 3 50 52 7 36 99 89 40 2 2 23 92 12 17 37 66 35 47 28 38 43 43 79 49 66 79 69 66 80 50 75 15 5 6 27 43 51 94 31 49 16 16 55 25 4 85 88 96 68 37 63 26 23...

output:

244

result:

ok single line: '244'

Test #77:

score: 0
Accepted
time: 0ms
memory: 5032kb

input:

364 345
28 12 35 20 55 58 85 12 53 38 34 9 85 63 3 17 99 57 76 35 72 14 11 95 76 37 25 17 31 42 60 5 60 57 63 64 84 64 80 59 64 12 40 57 31 98 41 24 27 36 62 76 82 38 63 77 2 81 46 73 94 12 60 34 22 5 93 36 23 1 75 13 19 14 19 35 14 36 21 4 37 72 94 2 19 30 44 89 71 81 85 89 24 37 55 64 26 12 5 31 5...

output:

106

result:

ok single line: '106'

Test #78:

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

input:

375 22
399362047 506599808 413562855 37438371 347952169 992995536 571546883 660167004 685829003 84317710 535041083 2370540 726813192 693669095 370080910 244484048 430929882 252024530 749148020 377653990 304117668 720369372 775048210 606098004 498609935 373526665 927755901 277925802 340501285 3747254...

output:

9298188406

result:

ok single line: '9298188406'

Test #79:

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

input:

643 518
612659459 274110128 354006412 798687917 169429650 76499112 534678439 268031844 481481205 682294742 713935356 922225730 451735323 23741768 755080592 383762639 484094434 479463890 755227767 79932286 789454488 748333745 678750276 50746966 286122964 608263626 123405268 90139346 59701201 89721777...

output:

1196615391

result:

ok single line: '1196615391'

Test #80:

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

input:

696 87
55895672 542605126 448475597 948622054 424252274 28559757 398889574 539008509 464277537 514817802 625262315 869935597 242232986 248227288 361497982 733332722 228412918 310909712 515001261 984934357 709073791 721628178 686011168 140077250 322960410 365911387 576754616 273040958 881419172 28603...

output:

4598246962

result:

ok single line: '4598246962'

Test #81:

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

input:

153 145
997865121 166694027 96104768 437233734 151358967 230342886 913219686 475763203 839097382 822817271 368265104 2991159 858844945 336904539 514430341 366167775 877749896 798820627 819997675 111424219 421082580 603574001 613970289 744311316 814487855 490433097 682160863 132593113 721366402 50136...

output:

1034048243

result:

ok single line: '1034048243'

Test #82:

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

input:

73 15
95 35 46 1 40 3 18 95 5 10 39 77 58 18 51 17 57 24 89 85 99 15 24 89 40 59 41 2 71 63 77 23 65 42 63 57 45 78 87 96 57 48 75 97 85 96 38 64 15 39 28 86 3 56 18 73 53 90 72 33 75 86 10 18 78 72 97 12 25 73 64 24 2

output:

307

result:

ok single line: '307'

Test #83:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

32 3
10 22 80 79 59 76 7 9 95 40 98 17 79 32 15 83 11 81 59 81 31 52 91 2 66 97 49 7 62 73 24 35

output:

687

result:

ok single line: '687'

Test #84:

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

input:

67 39
389065496 805109358 276729887 960174802 895416373 324090231 418108368 467278505 112248229 809530698 480711666 238761978 376464808 211868207 317348068 335905275 874422103 871875713 217079466 287406945 852824274 413705380 490472898 929846481 660151685 722998331 304316375 967003441 294311981 6631...

output:

1429158864

result:

ok single line: '1429158864'

Test #85:

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

input:

41 30
25542796 161684246 739866628 109056227 606157132 899072892 44899242 231584462 22005931 41852272 979084585 485153816 27743193 202227891 390019457 186269232 128238315 318503816 320761708 900399352 749315637 877083835 925707121 417311947 947398781 338810630 651199763 138537429 961463339 781415802...

output:

1161873493

result:

ok single line: '1161873493'

Test #86:

score: 0
Accepted
time: 109ms
memory: 434456kb

input:

10000 2
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

19997

result:

ok single line: '19997'

Test #87:

score: 0
Accepted
time: 88ms
memory: 304160kb

input:

10000 3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ...

output:

29997

result:

ok single line: '29997'

Test #88:

score: 0
Accepted
time: 95ms
memory: 199972kb

input:

10000 5
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000...

output:

4999000000000

result:

ok single line: '4999000000000'

Test #89:

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

input:

10000 4999
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100...

output:

5000000000

result:

ok single line: '5000000000'

Test #90:

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

input:

10000 9999
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100...

output:

3000000000

result:

ok single line: '3000000000'

Test #91:

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

input:

10000 10000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 10...

output:

1000000000

result:

ok single line: '1000000000'

Test #92:

score: 0
Accepted
time: 119ms
memory: 434376kb

input:

10000 2
10000 9999 9998 9997 9996 9995 9994 9993 9992 9991 9990 9989 9988 9987 9986 9985 9984 9983 9982 9981 9980 9979 9978 9977 9976 9975 9974 9973 9972 9971 9970 9969 9968 9967 9966 9965 9964 9963 9962 9961 9960 9959 9958 9957 9956 9955 9954 9953 9952 9951 9950 9949 9948 9947 9946 9945 9944 9943 9...

output:

25029995

result:

ok single line: '25029995'

Test #93:

score: 0
Accepted
time: 119ms
memory: 304088kb

input:

10000 3
10000 9999 9998 9997 9996 9995 9994 9993 9992 9991 9990 9989 9988 9987 9986 9985 9984 9983 9982 9981 9980 9979 9978 9977 9976 9975 9974 9973 9972 9971 9970 9969 9968 9967 9966 9965 9964 9963 9962 9961 9960 9959 9958 9957 9956 9955 9954 9953 9952 9951 9950 9949 9948 9947 9946 9945 9944 9943 9...

output:

16686662

result:

ok single line: '16686662'

Test #94:

score: 0
Accepted
time: 7ms
memory: 44548kb

input:

10000 909
10000 9999 9998 9997 9996 9995 9994 9993 9992 9991 9990 9989 9988 9987 9986 9985 9984 9983 9982 9981 9980 9979 9978 9977 9976 9975 9974 9973 9972 9971 9970 9969 9968 9967 9966 9965 9964 9963 9962 9961 9960 9959 9958 9957 9956 9955 9954 9953 9952 9951 9950 9949 9948 9947 9946 9945 9944 9943...

output:

60049

result:

ok single line: '60049'

Test #95:

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

input:

2 2
1 1

output:

1

result:

ok single line: '1'

Test #96:

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

input:

2 2
1000000000 1

output:

1000000000

result:

ok single line: '1000000000'

Test #97:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

2 10000
1000000000 999999999

output:

1000000000

result:

ok single line: '1000000000'

Test #98:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

3 2
1 1 1

output:

3

result:

ok single line: '3'

Test #99:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

3 2
1 1000000000 1

output:

1000000002

result:

ok single line: '1000000002'

Test #100:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

3 3
1 1000000000 1

output:

1000000000

result:

ok single line: '1000000000'

Test #101:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

3 10000
1 1000000000 1

output:

1000000000

result:

ok single line: '1000000000'

Test #102:

score: 0
Accepted
time: 0ms
memory: 3508kb

input:

5 3
1 1 4 4 4

output:

8

result:

ok single line: '8'

Extra Test:

score: 0
Extra Test Passed