QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#609247#5363. ZYB 的游览计划Idtwtei100 ✓2788ms31172kbC++142.3kb2024-10-04 11:28:102024-10-04 11:28:10

Judging History

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

  • [2024-10-04 11:28:10]
  • 评测
  • 测评结果:100
  • 用时:2788ms
  • 内存:31172kb
  • [2024-10-04 11:28:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define pb push_back
const int N=2e5+100,B=20,INF=1e9;
inline int chkmax(int &x,int y){ return y>x?x=y,1:0; }
#define rd read()
#define gc getchar() 
inline int read(){
	int x=0,f=0; char c=gc;
	for(;c<'0'||c>'9';c=gc) f|=(c=='-');
	for(;c>='0'&&c<='9';c=gc) x=(x<<1)+(x<<3)+(c^48);
	return f?-x:x;
}

int n,m,a[N];
vector<int> G[N];

int dfn[N],fdfn[N],d_c=0,st[N][B+5],dep[N];
inline int get(int x,int y){ return dfn[x]<dfn[y]?x:y; }
void dfs0(int u,int fu){
	st[dfn[u]=++d_c][0]=fu,fdfn[d_c]=u,dep[u]=dep[fu]+1;
	for(int v:G[u]) if(v!=fu) dfs0(v,u);
}
inline void init(){ for(int k=1;k<=B;++k) for(int i=1;i+(1<<k)-1<=n;++i) st[i][k]=get(st[i][k-1],st[i+(1<<(k-1))][k-1]); }
inline int flca(int x,int y){ if(x==y) return x; if((x=dfn[x])>(y=dfn[y])) swap(x,y); int k=__lg(y-(++x)+1); return get(st[x][k],st[y+1-(1<<k)][k]); }
inline int fdis(int x,int y){ return dep[x]+dep[y]-2*dep[flca(x,y)]; }

int f[2][N];
set<int> s; int dl,dr,dans;
void add(int x){
	if(x==1) return;
	auto pr=s.lower_bound(dfn[x]),nx=s.upper_bound(dfn[x]);
	if(pr==s.begin()) pr=s.end(); --pr;
	if(nx==s.end()) nx=s.begin();
	dans+=fdis(fdfn[*pr],x)+fdis(fdfn[*nx],x)-fdis(fdfn[*pr],fdfn[*nx]);
	s.insert(dfn[x]);
}
void del(int x){
	if(x==1) return;
	auto pr=s.lower_bound(dfn[x]),nx=s.upper_bound(dfn[x]);
	if(pr==s.begin()) pr=s.end(); --pr;
	if(nx==s.end()) nx=s.begin();
	dans+=fdis(fdfn[*pr],fdfn[*nx])-fdis(fdfn[*pr],x)-fdis(fdfn[*nx],x);
	s.erase(dfn[x]);
}
void mov(int ql,int qr){
	while(dl>ql) add(a[--dl]);
	while(dr<qr) add(a[++dr]);
	while(dl<ql) del(a[dl++]);
	while(dr>qr) del(a[dr--]);
}
inline int sol(int l,int r){ if(l>r) return 0; return mov(l,r),dans; }
void solve(int op,int l,int r,int cl,int cr){
	if(l>r||cl>cr) return; int mid=l+r>>1,p;
	for(int i=cl;i<=cr&&i<mid;++i) if(chkmax(f[op][mid],f[op^1][i]+sol(i+1,mid))) p=i;
	solve(op,l,mid-1,cl,p),solve(op,mid+1,r,p,cr);
}

int main(){

	n=rd,m=rd;
	for(int i=1;i<=n;++i) a[i]=rd;
	for(int i=1,x,y;i<n;++i) x=rd,y=rd,G[x].pb(y),G[y].pb(x);
	
	dfs0(1,0),init();
	
	for(int i=0;i<=m;++i) f[0][i]=-INF; f[0][0]=0;
	s.insert(1),dl=1,dr=0,dans=0;
	for(int i=1;i<=m;++i){
		for(int j=0;j<=n;++j) f[i&1][j]=-INF;
		solve(i&1,1,n,0,n-1);
	}

	printf("%d\n", f[m&1][n]);

	return 0;
}


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

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 2ms
memory: 10924kb

input:

5 2
2 4 3 5 1
1 2
2 3
3 4
4 5

output:

14

result:

ok single line: '14'

Test #2:

score: 5
Accepted
time: 2766ms
memory: 28920kb

input:

90752 2
88555 48815 61754 47133 45462 73740 84783 58077 73713 78537 14562 78533 71607 24890 16284 41187 78450 31531 25296 45169 55240 83197 82146 86338 83180 75924 9923 40553 84394 73069 7278 77214 24896 14446 87566 70680 48218 58608 86578 47698 86173 89371 77350 85782 36318 22735 80925 5435 76359 2...

output:

251418

result:

ok single line: '251418'

Test #3:

score: 5
Accepted
time: 2788ms
memory: 31172kb

input:

93770 2
89903 29857 80965 80811 71223 80535 36801 25153 57709 29654 38160 35249 58550 68675 29353 62251 50118 79990 51189 61691 79132 19597 57750 1034 90042 93286 75086 57631 92276 26985 52590 90754 16542 92552 80430 73904 35365 89129 1663 11819 55751 24513 88548 90162 83633 19731 68199 6748 27706 7...

output:

290726

result:

ok single line: '290726'

Test #4:

score: 5
Accepted
time: 1710ms
memory: 24412kb

input:

65317 2
51766 57961 28299 31999 40127 16772 33540 19124 26900 33659 7103 63514 2505 39507 56023 31079 63274 63343 14843 61644 28909 58494 61041 56428 65315 53077 63700 38453 61569 39339 5844 38272 51519 40290 26380 63569 37168 58037 59325 54243 64499 52417 37227 47397 54105 53297 16022 3375 22482 52...

output:

180930

result:

ok single line: '180930'

Test #5:

score: 5
Accepted
time: 1365ms
memory: 24060kb

input:

54968 2
32076 44969 33748 31214 39664 34931 30817 25648 47689 46763 47967 53937 53728 18220 27763 46030 53523 44219 20200 14610 40293 40336 29098 33745 16007 46631 45935 24773 34522 25436 54008 35558 34959 54454 51456 25414 16526 38487 28216 38555 35027 26147 24162 11326 46548 50826 48554 32604 4735...

output:

171654

result:

ok single line: '171654'

Test #6:

score: 5
Accepted
time: 1944ms
memory: 25744kb

input:

68335 2
28375 24392 60247 61323 52947 34744 57888 61373 50395 65896 19146 39921 65851 48750 1542 11291 32925 47723 58218 48669 10903 27842 45110 41451 62005 61905 38873 12161 53816 65654 43312 28094 51487 66072 63629 55510 47316 51979 64731 52920 67110 45018 28259 46018 60733 49970 51000 19511 24760...

output:

200690

result:

ok single line: '200690'

Test #7:

score: 5
Accepted
time: 2035ms
memory: 24996kb

input:

72649 2
71869 56974 5397 57803 33008 70619 3561 36980 64022 44606 20962 65004 62918 65560 59254 70785 22210 71921 58629 61718 14809 45500 45395 9868 54723 30438 24983 58229 42978 67848 32425 34444 69676 30915 68879 63038 63829 33271 30029 57654 58744 64114 18811 69970 60443 36161 69714 56496 9668 59...

output:

201180

result:

ok single line: '201180'

Test #8:

score: 5
Accepted
time: 2555ms
memory: 28136kb

input:

86016 2
66729 82992 85681 46404 58569 77836 82916 83518 79848 37068 43830 62675 56215 72709 15612 35712 65773 76805 85528 81357 56301 74881 13692 46936 50574 85728 82638 41595 70796 17045 61500 46114 79294 60756 56282 81104 70770 82699 72010 8531 66950 81157 70631 80579 6614 65467 42497 80999 63948 ...

output:

252628

result:

ok single line: '252628'

Test #9:

score: 5
Accepted
time: 2119ms
memory: 26952kb

input:

75667 2
15091 63031 65720 55413 44774 71773 51901 69149 48649 73881 61574 68157 65817 73499 30726 46050 71914 33687 31751 46428 71704 74847 44532 73723 53020 67563 55007 69177 62435 32197 63068 66348 36407 66223 11393 72153 39127 75129 54135 50349 64047 25960 70200 40639 57590 59123 58615 9518 73652...

output:

231734

result:

ok single line: '231734'

Subtask #2:

score: 10
Accepted

Test #10:

score: 10
Accepted
time: 398ms
memory: 12144kb

input:

760 217
632 417 493 400 316 482 542 614 36 134 604 291 745 484 451 746 518 378 487 650 633 223 601 259 33 257 309 683 705 627 513 670 130 395 512 115 466 376 575 356 180 716 539 403 431 563 568 468 596 239 296 379 537 224 526 215 725 234 663 603 401 21 75 660 506 393 105 88 462 620 449 338 276 200 4...

output:

35938

result:

ok single line: '35938'

Test #11:

score: 10
Accepted
time: 48ms
memory: 13344kb

input:

919 16
836 94 652 285 192 830 643 430 855 825 844 852 750 773 835 743 310 59 115 589 187 831 277 35 577 683 348 611 459 590 196 531 609 575 754 729 542 502 19 890 695 433 445 678 221 901 140 525 441 689 510 423 709 568 894 802 552 474 878 653 51 866 916 123 2 167 190 302 226 769 658 818 351 757 400 ...

output:

5682

result:

ok single line: '5682'

Test #12:

score: 10
Accepted
time: 212ms
memory: 12152kb

input:

727 116
382 218 586 528 66 508 58 216 234 251 629 222 403 356 596 577 92 221 167 84 417 226 595 388 127 341 656 715 180 71 67 429 25 308 194 494 144 196 675 556 201 289 711 727 594 304 188 330 581 517 471 441 462 254 654 203 159 472 273 280 442 603 677 650 317 389 545 265 475 499 362 15 686 239 205 ...

output:

40024

result:

ok single line: '40024'

Test #13:

score: 10
Accepted
time: 187ms
memory: 12252kb

input:

961 67
180 513 138 39 787 472 499 847 561 275 602 804 331 191 492 75 718 287 647 724 323 224 436 442 389 605 250 679 59 19 746 177 692 461 115 786 289 267 424 58 952 541 422 397 401 484 273 445 660 925 806 789 744 553 314 435 253 209 530 462 594 795 745 644 281 427 637 141 808 76 378 351 348 464 35 ...

output:

13302

result:

ok single line: '13302'

Test #14:

score: 10
Accepted
time: 446ms
memory: 12348kb

input:

979 185
384 598 917 477 487 141 460 529 299 53 462 614 238 772 535 933 915 588 789 816 710 660 866 158 83 139 69 473 965 908 434 733 582 132 318 722 880 18 478 426 154 262 809 216 576 781 375 170 736 130 765 753 122 456 526 373 734 222 425 693 595 877 818 482 114 68 263 308 891 390 845 320 447 922 3...

output:

11084

result:

ok single line: '11084'

Test #15:

score: 10
Accepted
time: 321ms
memory: 10840kb

input:

515 312
449 338 205 182 444 131 496 370 300 32 343 143 475 133 43 172 385 266 283 227 228 458 470 469 196 399 136 329 146 218 367 83 30 304 99 158 26 268 435 1 206 494 324 7 140 506 155 113 112 162 219 109 393 70 490 166 359 231 251 233 277 373 222 246 501 229 429 169 12 473 316 313 264 122 168 398 ...

output:

47230

result:

ok single line: '47230'

Test #16:

score: 10
Accepted
time: 224ms
memory: 12416kb

input:

771 119
83 275 752 576 319 581 324 287 496 137 114 73 541 100 418 488 120 701 234 539 554 677 194 91 561 369 171 230 301 632 389 211 655 157 208 586 606 377 169 724 364 714 538 743 749 407 599 193 311 233 65 550 640 513 135 615 1 421 354 108 726 633 290 682 41 270 22 302 115 670 614 678 246 605 509 ...

output:

12334

result:

ok single line: '12334'

Test #17:

score: 10
Accepted
time: 432ms
memory: 12180kb

input:

971 164
241 934 565 457 914 803 892 300 927 270 769 177 930 250 701 287 623 510 915 164 483 385 29 438 98 431 145 715 855 337 408 303 506 758 795 700 396 495 290 531 235 719 570 174 346 339 898 607 295 808 10 496 561 875 931 155 479 94 275 317 368 361 669 788 366 175 801 709 908 364 616 804 965 412 ...

output:

58248

result:

ok single line: '58248'

Test #18:

score: 10
Accepted
time: 319ms
memory: 12144kb

input:

727 189
725 237 275 99 597 563 257 436 396 342 397 299 611 74 395 701 594 252 357 619 428 115 439 229 339 223 91 344 555 484 97 8 722 133 677 338 2 704 254 265 271 302 231 557 467 391 715 244 498 421 235 112 367 487 29 368 365 469 547 595 60 635 141 171 380 156 170 377 613 316 453 708 44 258 372 452...

output:

33166

result:

ok single line: '33166'

Subtask #3:

score: 15
Accepted

Dependency #2:

100%
Accepted

Test #19:

score: 15
Accepted
time: 177ms
memory: 13336kb

input:

5888 5
1718 907 2359 17 692 2242 39 1614 444 5711 2566 894 4118 3472 3556 2148 616 2871 1299 2933 1836 3376 2157 4664 4793 3123 1129 1074 521 2266 2864 5201 936 5803 4916 5196 1904 1427 4921 2065 2833 3131 3107 1555 2512 5250 4887 4839 3986 3143 4554 4304 4556 3166 1705 3365 3929 2879 4693 3086 4382...

output:

23844

result:

ok single line: '23844'

Test #20:

score: 15
Accepted
time: 287ms
memory: 12984kb

input:

5581 9
1454 2110 642 4210 4160 910 4349 5071 2724 989 5207 4612 2954 514 3283 1111 4301 389 4428 130 3064 3189 2505 3844 4866 3434 1858 2169 2386 4970 2726 3012 621 385 3410 5403 4050 4238 139 5431 3160 853 1133 4403 2176 1264 343 3760 570 4331 3214 2872 1550 5007 2772 2478 1636 4453 5172 1547 3202 ...

output:

35122

result:

ok single line: '35122'

Test #21:

score: 15
Accepted
time: 662ms
memory: 12560kb

input:

5757 21
5119 4440 256 3691 2048 4043 2239 5289 3247 3824 4734 219 3258 5392 2558 5011 5295 4672 4017 2728 5657 1606 3755 5241 5649 2970 1131 3922 2840 409 2435 327 5513 5074 2164 5291 5017 2974 512 2776 2972 4553 111 2687 3382 5008 2660 4464 1444 3873 3701 2548 2812 369 3823 2405 1481 2098 2912 5585...

output:

76420

result:

ok single line: '76420'

Test #22:

score: 15
Accepted
time: 932ms
memory: 13552kb

input:

9482 16
6630 3953 4314 2316 7432 8505 9370 3821 3527 1433 3063 5514 2601 4671 1032 5520 9211 2374 6594 7797 2261 6233 4325 2432 6214 1230 2628 6109 2581 6494 6064 2014 8654 566 8885 7677 1243 4025 1009 5396 1679 986 9476 9255 2431 6191 5922 6690 7665 1165 4559 4978 8575 173 4431 1783 5106 2053 6046 ...

output:

56384

result:

ok single line: '56384'

Test #23:

score: 15
Accepted
time: 981ms
memory: 12564kb

input:

5610 34
4266 998 2201 4812 3413 2509 1223 1116 4063 3671 1759 3160 222 2046 4875 3184 2653 3609 3117 4597 1108 5308 1061 3699 4277 3426 3546 1444 5539 5305 4586 2976 3568 2916 1090 2950 5029 2772 441 3078 2235 476 4699 1944 5240 2207 372 1358 2516 197 1109 4166 4512 2324 402 506 2757 3553 4934 4441 ...

output:

106410

result:

ok single line: '106410'

Test #24:

score: 15
Accepted
time: 891ms
memory: 12328kb

input:

9796 14
1330 3337 3269 3377 7636 1461 3560 4842 7829 980 2712 5041 3026 3171 8253 6779 6239 6098 430 7242 7983 7816 9174 6769 9414 1349 9276 7448 8086 5963 7310 9674 9435 421 8406 4821 5589 7640 4444 1720 7486 8343 895 13 3527 2576 8042 7738 7185 8066 6257 5046 2 4416 5539 9166 8442 5880 3978 6450 6...

output:

74648

result:

ok single line: '74648'

Test #25:

score: 15
Accepted
time: 926ms
memory: 13652kb

input:

9447 16
2362 8779 3329 982 4374 959 2428 880 3577 6494 5461 1677 5995 4832 3760 1770 1085 7667 8084 2342 7000 9117 7296 4447 3370 8757 1069 4492 7719 7433 2610 6570 3155 9157 785 5207 5367 3953 3788 569 521 4927 6102 314 6018 2216 2325 4665 5273 2474 8697 2456 2810 4183 3528 4491 7831 1402 4526 7089...

output:

56042

result:

ok single line: '56042'

Test #26:

score: 15
Accepted
time: 1162ms
memory: 13092kb

input:

9709 19
2020 1513 8246 8366 775 3581 1546 8291 7922 4734 2941 2555 389 1723 4575 2928 7676 4249 16 9490 2133 4623 7311 3059 7686 6578 4847 1388 1017 1514 3900 7736 3566 709 6111 3032 3111 8087 6665 9462 9447 5042 573 8721 518 4466 9379 8163 8528 7963 3742 1899 3528 4696 8805 4380 8642 3029 6826 8872...

output:

123260

result:

ok single line: '123260'

Test #27:

score: 15
Accepted
time: 913ms
memory: 12920kb

input:

9151 16
3040 8481 1253 9082 6361 4127 8823 1041 2486 6558 9025 7962 9128 8996 14 8206 2511 4855 6154 2973 5494 6712 7699 5173 4548 2445 8320 1131 1840 8965 8922 3089 8200 7673 2659 5412 5577 7812 900 6984 6394 5158 9023 1627 6555 1006 1849 4605 384 143 3012 1085 7200 5050 8497 5601 2379 2713 1659 53...

output:

72992

result:

ok single line: '72992'

Test #28:

score: 15
Accepted
time: 966ms
memory: 13012kb

input:

9780 16
5936 8229 6637 3017 8301 7926 683 4261 6024 622 458 142 5084 4317 6367 2096 6368 1457 4768 2467 7292 3571 3039 5186 1001 7039 1034 3334 6807 2454 4219 5990 9682 2659 7821 9057 6324 3269 8363 4995 8014 161 3245 3554 1346 3506 5637 5683 6342 3879 2497 4285 1621 4163 5710 7705 2701 9455 1838 61...

output:

58460

result:

ok single line: '58460'

Subtask #4:

score: 10
Accepted

Test #29:

score: 10
Accepted
time: 692ms
memory: 14532kb

input:

14878 6
1663 4532 2022 11114 1768 7744 12403 7698 14863 1406 13199 9405 3528 9898 1205 3076 11342 7459 9401 10025 14498 7178 11457 1802 9923 1648 13136 10720 3002 7332 13780 2094 1716 13215 8118 318 11186 14833 7941 8174 8999 6189 7504 13738 4933 3367 12973 1889 9835 4080 3546 1993 1861 11613 2504 1...

output:

78002

result:

ok single line: '78002'

Test #30:

score: 10
Accepted
time: 1512ms
memory: 16368kb

input:

24636 7
12167 7049 12913 9008 23642 14034 22429 15360 16128 13951 22411 23901 14309 23575 3041 22948 18403 6420 23362 8205 22117 8264 4985 10566 23946 6690 23211 3785 12602 8004 14405 12431 16247 11244 2609 20547 15874 22972 15889 23107 5516 15507 7804 9729 23913 3705 21184 9988 15513 15567 5773 245...

output:

139942

result:

ok single line: '139942'

Test #31:

score: 10
Accepted
time: 1326ms
memory: 16704kb

input:

28777 5
3114 25599 5461 12359 9126 3562 15686 26516 7699 13051 21415 23352 17530 15810 5010 26644 5003 10378 28447 643 4248 5626 27227 28668 10795 7453 8223 23524 13021 4276 19362 3886 14958 19905 658 23584 20028 28592 5590 10278 11631 14519 8792 18493 6786 25778 21658 6891 26711 14785 25071 24747 2...

output:

115786

result:

ok single line: '115786'

Test #32:

score: 10
Accepted
time: 1868ms
memory: 20640kb

input:

52146 3
33314 45821 7078 37782 29370 29486 46473 44353 24139 1100 34550 38329 47860 26414 24351 33775 23138 36289 49679 23188 47590 34612 50336 44211 30105 43691 39467 32464 24104 44400 43750 28231 39219 31463 750 45411 45673 28738 46536 52132 32660 39989 37018 25355 43732 26363 42964 9967 40492 272...

output:

171986

result:

ok single line: '171986'

Test #33:

score: 10
Accepted
time: 1826ms
memory: 21692kb

input:

50849 3
39565 47876 84 11231 35992 14685 25222 48911 10169 43305 39934 46476 17222 17449 14869 48016 10568 33399 45577 2023 8134 32067 39984 44765 25555 36738 27234 35615 47330 50729 40495 39647 23364 21371 39116 31307 2126 8911 21905 29909 10832 50772 47388 39033 49574 25804 33111 30930 45516 13313...

output:

186762

result:

ok single line: '186762'

Test #34:

score: 10
Accepted
time: 2265ms
memory: 22784kb

input:

59553 3
11160 47277 7851 15595 56570 40146 58938 12198 57479 35980 18855 54715 29926 59357 28832 27143 28798 4408 50852 23333 54308 21117 10817 16337 46412 58906 5619 25987 3412 58950 20704 46605 28555 14807 17148 17185 28412 175 42110 33226 2458 33583 6886 40543 42672 26156 21014 32467 27091 11872 ...

output:

220062

result:

ok single line: '220062'

Test #35:

score: 10
Accepted
time: 2276ms
memory: 20892kb

input:

50000 4
45738 45181 32512 6389 15451 16925 31260 442 48643 43861 47173 37110 9763 28249 27947 9411 35857 38856 38454 13040 42902 49193 3095 24815 31282 5337 7746 35832 2770 36210 35432 19435 24512 32197 38769 49628 28763 21840 41823 45000 40728 38326 25058 47003 36008 6040 13825 40103 36794 28733 46...

output:

184530

result:

ok single line: '184530'

Test #36:

score: 10
Accepted
time: 1558ms
memory: 16028kb

input:

20000 10
14868 15331 9254 1880 19085 19308 6895 8083 15248 10502 16877 11536 16186 5244 2000 9564 7218 10907 18935 16890 15667 2657 7991 2017 6117 12725 6304 11785 7626 19147 3438 4241 17891 3934 12863 16907 8957 10903 5970 17954 11070 5894 1328 11794 18282 2304 15320 14053 9805 1069 15459 10790 101...

output:

102964

result:

ok single line: '102964'

Test #37:

score: 10
Accepted
time: 682ms
memory: 12252kb

input:

2000 100
1773 1655 1366 357 1930 977 1690 1617 85 294 43 1327 1864 336 1802 1780 1665 681 686 231 94 64 1754 246 557 1976 1425 212 1472 1940 725 297 1112 1262 1560 1721 1556 1737 210 1243 615 1019 1550 767 1005 1404 1495 526 1483 1450 1761 1061 531 1951 1909 1169 835 518 748 1809 1320 595 1570 1593 ...

output:

33116

result:

ok single line: '33116'

Test #38:

score: 10
Accepted
time: 985ms
memory: 13616kb

input:

5000 40
4418 4807 2144 4386 953 3374 2445 456 2855 3472 3906 12 3360 3854 2233 2109 4416 3843 409 2102 1818 909 2191 1242 3469 1612 4703 391 2951 4117 3381 2256 3334 3669 122 4231 893 3511 4415 1048 4256 4816 323 4811 3538 2480 2467 2726 4070 1841 1882 4970 4420 4393 4047 833 1109 667 2323 4369 4074...

output:

209522

result:

ok single line: '209522'

Test #39:

score: 10
Accepted
time: 824ms
memory: 24168kb

input:

50000 4
50000 49999 49998 49997 49996 49995 49994 49993 49992 49991 49990 49989 49988 49987 49986 49985 49984 49983 49982 49981 49980 49979 49978 49977 49976 49975 49974 49973 49972 49971 49970 49969 49968 49967 49966 49965 49964 49963 49962 49961 49960 49959 49958 49957 49956 49955 49954 49953 4995...

output:

399980

result:

ok single line: '399980'

Test #40:

score: 10
Accepted
time: 1599ms
memory: 17964kb

input:

32767 5
18474 28974 16167 19316 17139 8871 6525 13889 32540 21248 2355 10010 7072 28823 32234 8311 9993 23456 5481 30525 6320 21723 16139 31091 30178 26090 31360 1871 10189 9857 27187 10773 10620 24757 13466 29073 32092 19727 16964 2095 17391 32526 30369 31634 6164 21185 6829 6233 21408 24409 6107 1...

output:

145290

result:

ok single line: '145290'

Test #41:

score: 10
Accepted
time: 1876ms
memory: 17148kb

input:

32767 6
27120 27461 27104 30174 17357 17628 21948 25708 19784 10109 13732 29942 32746 20876 1033 2090 27457 7193 29496 13105 597 24910 605 13987 17697 27197 29951 27510 17470 20783 12200 28735 20806 26578 9783 32001 26472 9923 23739 16446 6215 138 31237 16693 21384 22993 4686 26770 7911 1592 14024 2...

output:

157096

result:

ok single line: '157096'

Subtask #5:

score: 60
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #42:

score: 60
Accepted
time: 1179ms
memory: 17024kb

input:

24442 5
1236 480 15523 23284 6456 22169 9363 22113 17465 21808 886 5891 9718 23086 21912 22138 4843 18865 19000 17177 14223 14161 16474 6431 2915 18460 14271 12734 21936 17728 14229 18224 17041 12374 14935 14050 23567 21432 3734 20309 1987 5951 5465 7073 23193 15531 18544 20307 2533 6422 4138 7514 1...

output:

244292

result:

ok single line: '244292'

Test #43:

score: 60
Accepted
time: 1360ms
memory: 15168kb

input:

21176 7
17379 10050 10128 4464 2624 20388 13625 15076 11319 15487 19499 3914 6078 1917 19933 18234 7563 12748 15809 15044 20171 5904 15599 9069 16251 6130 3988 20796 1493 7301 9118 19233 13102 6041 5145 9854 19183 20523 17787 12552 6343 2500 14607 14372 9488 15961 2382 20082 7926 14090 12298 14804 7...

output:

296222

result:

ok single line: '296222'

Test #44:

score: 60
Accepted
time: 1139ms
memory: 16780kb

input:

24107 5
7657 16362 9857 10914 11802 20195 21345 8075 6298 15449 14937 23718 22654 15271 18430 13346 5351 11170 12452 21944 12437 9148 1351 21591 21330 16477 10526 23550 3851 13456 21907 7937 17874 18947 20284 5162 10730 12457 14981 22628 12550 22525 17635 3770 23737 7788 23740 4156 9805 14993 14370 ...

output:

240988

result:

ok single line: '240988'

Test #45:

score: 60
Accepted
time: 1503ms
memory: 19780kb

input:

42637 3
1449 3631 22534 10886 41056 35958 10486 12978 26952 36808 31511 14273 5243 42400 32069 27507 19919 37399 24156 27521 31284 32002 27787 28742 38495 27215 32652 32135 38491 20199 40769 1645 26003 26253 14300 23089 26340 36019 6006 28676 13807 20672 35745 22741 36707 10191 29096 37528 17391 271...

output:

255792

result:

ok single line: '255792'

Test #46:

score: 60
Accepted
time: 2252ms
memory: 21696kb

input:

47127 4
31539 13524 37964 38890 31870 196 14331 44086 1199 10402 36747 33708 32184 20918 46022 46610 23231 27893 44932 38086 7323 30963 8344 6223 17675 24576 37935 17047 46965 17928 45007 46001 46713 15255 8350 24003 17943 33746 41827 37773 25068 18579 45372 5614 10597 38999 8341 46201 22902 18223 2...

output:

376982

result:

ok single line: '376982'

Test #47:

score: 60
Accepted
time: 1784ms
memory: 22232kb

input:

48250 3
37748 38262 46919 33804 6546 21981 7568 14253 6927 20093 32197 36440 19912 38278 3077 25635 24271 45620 43894 14131 38593 36315 31147 22730 32677 16495 4851 24763 24401 11069 30432 32217 29350 30626 38318 38389 28026 37690 17425 28452 13492 30051 42313 8834 39556 12268 44138 16029 10309 2610...

output:

289462

result:

ok single line: '289462'

Test #48:

score: 60
Accepted
time: 1976ms
memory: 20628kb

input:

42564 4
3818 30003 11115 29916 9407 37873 7028 33971 26695 25973 25451 7590 40240 8945 27604 4288 35621 11935 39598 9861 27374 21332 40868 22349 26010 34986 24433 28125 27429 37382 38791 36231 15798 30693 24370 6345 13523 12110 32335 1920 36273 31455 40580 2863 36861 9008 31617 25362 28053 19012 422...

output:

340424

result:

ok single line: '340424'

Test #49:

score: 60
Accepted
time: 2114ms
memory: 20856kb

input:

45583 4
40321 18348 35053 29318 19379 28945 20418 43917 30688 38111 12068 41150 31910 28014 23915 30586 30748 10000 17786 43021 32396 31690 9973 3579 27104 6024 13376 40808 21493 26534 1114 16349 19256 29799 41268 16748 44530 45353 41756 28918 35265 30091 34344 23696 40401 15612 23871 32631 29984 44...

output:

364578

result:

ok single line: '364578'