QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#557424#6298. ColoringdaduoliWA 144ms396492kbC++143.5kb2024-09-11 09:41:142024-09-11 09:41:14

Judging History

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

  • [2024-09-11 09:41:14]
  • 评测
  • 测评结果:WA
  • 用时:144ms
  • 内存:396492kb
  • [2024-09-11 09:41:14]
  • 提交

answer

#pragma GCC optimize(3,"inline","Ofast")
#include<bits/stdc++.h>
#define Yzl unsigned long long
#define pb emplace_back
#define pi pair<LL,LL>
#define mp make_pair
#define fi first
#define se second
typedef long long LL;

using namespace std;

const Yzl Lty=20120712;

const int MAXN=5010;
const LL inf=1e18;
int n,s,V;
LL w[MAXN],p[MAXN],a[MAXN],ind[MAXN],dep[MAXN],cir[MAXN],len,tot;
LL f[MAXN][MAXN],g[MAXN];
bool vis[MAXN];
vector<int> e[MAXN];
void add(int f,int t) {
	e[f].pb(t);
}
void dfs(int u,int fa) {
	vis[u]=1; dep[u]=dep[fa]+1; ind[++tot]=u;
	for(auto t:e[u]) {
		if(!vis[t]) dfs(t,u);
		else {
			for(int i=1;i<=dep[u];++i) cir[++len]=ind[i];
			return ;
		}
		if(len) return ;
	} --tot;
}
int gyyddb;
int sz[MAXN];
void rdfs(int u,int fa) {
	sz[u]=3;
	for(int i=1;i<=V;++i) f[u][i]=0;
	for(auto t:e[u]) if(!vis[t]) {
		rdfs(t,u);
		for(int j=1;j<=V;++j) g[j]=-inf;
		for(int j=1;j<=sz[u];++j) 
			for(int q=1;q<=sz[t];++q) {
				g[max(j,q)]=max(g[max(j,q)],f[u][j]+f[t][q]);
			}
		sz[u]=max(sz[u],sz[t]+1);
		for(int j=1;j<=sz[u];++j) {
			f[u][j]=g[j];
		}
	}
	if(vis[u]) return ;
	for(int i=1;i<=V;++i) {
		f[u][i]=f[u][i]-(i-1)*p[u];
		if(!(i&1)) f[u][i]+=w[u];
	}
}
LL h[MAXN][MAXN];
LL lp[MAXN],lw[MAXN];
void sub3() {
	for(int i=1;i<=len;++i) vis[cir[i]]=1;
	for(int i=1;i<=len;++i) rdfs(cir[i],0);
	for(int i=1;i<=len;++i) {
		lp[i]=lp[i-1]+p[cir[i]];
		lw[i]=lw[i-1]+w[cir[i]];
		for(int j=1;j<=V;++j) f[cir[i]][j]=max(f[cir[i]][j],f[cir[i]][j-1]);
		if(i>1) for(int j=1;j<=V;++j) f[cir[i]][j]+=f[cir[i-1]][j];
	} LL ans=-inf;
	for(int i=1;i<=len;++i) {
		for(int j=2;j<=V;++j) h[i][j-1]=-lp[i]*(j-1)+(j%2==0)*lw[i]+f[cir[i]][j];
		for(int j=1;j<=V;++j) {
			LL ls=h[i-1][j];
			h[i][j]=max(h[i][j],ls-p[cir[i]]*(j-1)+(j%2==0)*w[cir[i]]+(f[cir[i]][j]-(i>1?f[cir[i-1]][j]:0)));
		}
		for(int j=2;j<=V;++j) {
			LL ls=h[i][j]-(lp[len]-lp[i])*(j-2)+(j%2==1)*(lw[len]-lw[i])+(f[cir[len]][j-1]-f[cir[i]][j-1]);
			ans=max(ans,ls);
		}
	} 
	for(int i=1;i<=V;++i) {
		ans=max(ans,h[len][i]);
	}
	printf("%lld\n",ans+p[s]);
}
void sub2() { vis[s]=1;
	rdfs(s,0); LL ans=-inf;
	for(int i=2;i<=V;++i) ans=max(ans,f[s][i]-(LL)(i-1)*p[s]+(i%2==0)*w[s]);
	printf("%lld\n",ans+p[s]);
}
LL F[MAXN];
void DFS(int u) {
	F[u]=w[u];
	for(auto t:e[u]) if(t!=s) {
		DFS(t);
		F[u]+=max(F[t]-p[t],0ll);
	}
}
void sub1() { vis[s]=1; vis[a[s]]=1;
	rdfs(s,0); LL ans=-inf;
	for(int i=2;i<=V;++i) ans=max(ans,f[s][i]-(LL)(i-1)*p[s]+(i%2==0)*w[s]);
	DFS(s);
	printf("%lld\n",max(ans+p[s],F[s]));
}
void vmain() {
	scanf("%d%d",&n,&s); ++gyyddb;
	len=tot=0; V=n+2;
	for(int i=0;i<=n;++i) {
		vis[i]=0; e[i].clear(); sz[i]=0;
		for(int j=0;j<=V;++j) f[i][j]=-inf,h[i][j]=-inf;
	}
	bool sf=1;
	for(int i=1;i<=n;++i) scanf("%lld",&w[i]);
	for(int i=1;i<=n;++i) scanf("%lld",&p[i]),(p[i]!=0)&&(sf=0);
	for(int i=1;i<=n;++i) {
		scanf("%lld",&a[i]);
		add(a[i],i);
	} 
//	if(gyyddb==206) {
//		cout<<n<<" "<<s<<endl;
//		for(int i=1;i<=n;++i) cout<<w[i]<<' '; puts("");
//		for(int i=1;i<=n;++i) cout<<p[i]<<' '; puts("");
//		for(int i=1;i<=n;++i) cout<<a[i]<<" "; puts("");
//		exit(0);
//	}
	dfs(s,0); for(int i=1;i<=n;++i) vis[i]=0;
//	cout<<len<<' ';
//	if(n==5000) cout<<len<<' ';
	if(!len) {
		sub2();
		return ;
	}
	if(len==2) {
		sub1();
		return ;
	} sub3();
}
int main () {
	//freopen("color.in","r",stdin);
	//freopen("color.out","w",stdout);
	int T=1; //scanf("%d",&T);
	while(T--) vmain();
	return 0;
}
/*
1159138015
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 8036kb

input:

3 1
-1 -1 2
1 0 0
3 1 2

output:

1

result:

ok 1 number(s): "1"

Test #2:

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

input:

10 8
36175808 53666444 14885614 -14507677 -92588511 52375931 -87106420 -7180697 -158326918 98234152
17550389 45695943 55459378 18577244 93218347 64719200 84319188 34410268 20911746 49221094
8 1 2 2 8 8 4 7 8 4

output:

35343360

result:

ok 1 number(s): "35343360"

Test #3:

score: 0
Accepted
time: 27ms
memory: 396208kb

input:

5000 1451
531302480 400140870 -664321146 -376787089 -440627168 -672055995 924309614 2764785 -225700856 880835131 -435550509 162278080 -635253658 251803267 -499868931 213283508 603121701 -603347266 541062018 -502078443 -585620031 486788884 864390909 -670529282 -63580194 512939729 691685896 481123612 ...

output:

83045140866

result:

ok 1 number(s): "83045140866"

Test #4:

score: 0
Accepted
time: 43ms
memory: 396488kb

input:

5000 325
790437050 -881570876 262369906 -462921420 -706598183 -486649546 -226864203 505745549 30451944 124046215 968419787 -21612898 145640891 11293206 830678227 214238313 -277762746 363570356 -123386912 -428728586 -928118626 44181027 -201770288 -776436064 -758985629 -330862963 -543373739 -904928126...

output:

484763000532

result:

ok 1 number(s): "484763000532"

Test #5:

score: 0
Accepted
time: 23ms
memory: 396064kb

input:

5000 4607
680975399 657968174 934047594 549055751 -677601906 596210389 865855282 82355240 -761574106 735853519 -869885284 249543935 992464614 770783145 530083741 -846596899 657436500 -165262643 664242609 -355378729 -934180733 970169392 170553447 808713917 -790827552 927447834 -353592386 697328858 -9...

output:

115329035

result:

ok 1 number(s): "115329035"

Test #6:

score: 0
Accepted
time: 40ms
memory: 396220kb

input:

5000 1889
571513748 -139398179 237129062 -340222790 -648605629 -484432867 -94780943 585336004 -861292487 -347660823 -402754561 -477474972 207884555 -235305792 -565925744 -552584412 963481326 261922222 541534795 -987061581 -276679328 822528827 507932827 -914620698 -486232986 -113967286 205280230 -121...

output:

1212882154486

result:

ok 1 number(s): "1212882154486"

Test #7:

score: 0
Accepted
time: 24ms
memory: 396492kb

input:

5000 3754
830648318 210762768 -908806750 -426357121 -914576644 593993710 102368241 -456912987 666043575 -254435419 304220058 410438717 349675568 -994795731 896735039 -553539217 -343155079 -432210729 -713794273 913711724 -987774144 748517191 -845312206 20527478 -181638420 636923229 720531586 -9135341...

output:

-6627360

result:

ok 1 number(s): "-6627360"

Test #8:

score: 0
Accepted
time: 43ms
memory: 396060kb

input:

5000 1733
721186667 -692192775 -211888218 217524159 -254176586 408587261 -36326612 -664926459 765761956 866242723 -205685555 269773535 565095510 -754285670 -227544334 480865094 -17796124 -823837600 -296119167 840361867 625240031 305909335 182691585 757838041 213480342 528475390 -867186722 705934838 ...

output:

849669910168

result:

ok 1 number(s): "849669910168"

Test #9:

score: 0
Accepted
time: 24ms
memory: 396160kb

input:

5000 1204
141738463 628860490 625744887 210769564 442514581 486663190 -242518671 337668386 999215523 746750082 975645653 257458899 589712130 -123743308 583663272 894458166 280353222 157069774 15929484 380801257 351285801 -294094478 962774361 429288997 917391381 373973523 587493899 580062253 19062877...

output:

1479061343

result:

ok 1 number(s): "1479061343"

Test #10:

score: 0
Accepted
time: 49ms
memory: 396332kb

input:

5000 4555
32276812 -405257787 928826356 1936603 708485596 301256741 176477041 209245369 435370391 63590094 582143858 485389936 436535852 -883233248 988101496 526816751 586398048 253729353 188188962 307451400 357347908 515050134 5186448 535195778 244200595 560492976 807777963 77495694 616380893 -2363...

output:

2073230674059

result:

ok 1 number(s): "2073230674059"

Test #11:

score: 0
Accepted
time: 27ms
memory: 396056kb

input:

5000 4571
922815163 886687794 600504043 88070933 974456610 410817584 479031631 80822352 535088772 675397399 483609355 713320973 946923086 -347755895 318910790 527771556 966071802 55421640 65481148 234101543 699846504 777474987 342565827 272506339 939606030 83448918 954433099 501300208 410729227 8297...

output:

-3891478

result:

ok 1 number(s): "-3891478"

Test #12:

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

input:

5000 1409
181949731 958052383 903585512 174205264 650493041 -594007355 118022709 288835823 634807153 -287204702 311445924 646284719 498779515 107245833 649720085 865162850 -935680139 152081218 942773334 865784395 410941319 629834422 679945207 378413120 971447953 680033788 469684453 293700941 2050775...

output:

2221363607186

result:

ok 1 number(s): "2221363607186"

Test #13:

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

input:

5000 3299
72488080 439482389 501634271 670405012 916464056 408600905 51981079 160412806 70962021 193979298 917944130 800586828 9166748 866735773 685562088 866117655 315353892 617337017 820065520 792434538 48407206 850790078 17324586 -779287194 666853386 866553242 -616339589 86101674 335862382 532869...

output:

1617908929

result:

ok 1 number(s): "1617908929"

Test #14:

score: 0
Accepted
time: 38ms
memory: 396192kb

input:

5000 1001
331622650 215879686 468279251 756539343 551031290 591790676 59568377 663393570 -170680402 437190382 450813407 733550573 855990471 36291127 -384967603 867072460 -989994938 713996596 992324998 719084681 759502021 113214929 649671257 516597755 -993662601 758105403 131590944 509906188 42517800...

output:

2087483384058

result:

ok 1 number(s): "2087483384058"

Test #15:

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

input:

5000 1719
-617898668 -614988385 -924598922 -227756070 -10818096 -404529485 -360613370 -528639445 -447593599 -900483874 -809552895 -47179441 -188236695 -856837968 -948109071 -561054704 -988424287 -398047675 -578215418 254978826 -264566965 -907327637 -583701525 -243272794 -762297189 -556924717 -489198...

output:

-4476415

result:

ok 1 number(s): "-4476415"

Test #16:

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

input:

5000 3204
-508437017 -465014610 -891243901 313890401 -276789111 -587719256 -999604449 -736652917 -547311980 -512291177 -5985683 -570077770 -403656637 -321360614 -278918365 -562009509 -368098040 -494707254 -455507604 -181628969 -975661781 -464719781 -921080905 -349179575 -457702623 -448476879 -340885...

output:

43714478273

result:

ok 1 number(s): "43714478273"

Test #17:

score: 0
Accepted
time: 33ms
memory: 396152kb

input:

5000 4673
767571586 -241411908 -489292661 -105057440 -247792833 402312807 -302159038 -903197192 -647030361 -124098481 243887669 -134445296 -545447650 -80850553 -978323881 -562964314 -674142866 -959963053 -627767082 -403246404 -613127667 -685675436 -889864064 -455086356 -489544546 971432821 -85613726...

output:

-9387015

result:

ok 1 number(s): "-9387015"

Test #18:

score: 0
Accepted
time: 47ms
memory: 396152kb

input:

5000 2976
-658109936 -312776497 -792374129 -191191771 -218796556 -880469869 -941150117 -406177955 -451781449 -735905785 -145353166 -67409041 -465900300 -840340492 -309133175 -195322899 -348783911 -56622631 -505059267 -329896547 -324222482 -243067580 -522210735 -487364210 -184949980 -862984983 -29775...

output:

229720327314

result:

ok 1 number(s): "229720327314"

Test #19:

score: 0
Accepted
time: 23ms
memory: 395992kb

input:

5000 3229
-548648285 -794206504 -464051817 -277326101 484767571 -695063420 -170075778 -277754938 -182903610 -642680381 -46818663 -590307370 -607691314 -304863139 -344975178 -196277704 -23424956 -858314919 -382351453 -256546690 -961688370 -169055944 -564622823 593270991 511759195 -49504435 -518043757...

output:

-7800163

result:

ok 1 number(s): "-7800163"

Test #20:

score: 0
Accepted
time: 51ms
memory: 396108kb

input:

5000 2440
-807782855 -570603801 -767133285 -68493140 455771294 -804624263 -177663076 -485768409 -987654700 -254487685 -579687941 -523271116 -823111255 -64353078 675784473 -197232509 -403098710 -954974498 -554610931 -888229542 672783185 726448088 -902002202 -699177772 -912197337 -941056598 -664698893...

output:

117717318452

result:

ok 1 number(s): "117717318452"

Test #21:

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

input:

5000 3495
-7950336 228171386 -221783218 -94840936 930052392 -520974815 -231590309 -90312035 -403830060 346536106 -919845250 941316291 -972056311 999617154 370345344 -862922981 -534367848 -881269525 -297945338 8854844 917586160 -61181668 818483877 -886000936 754484642 305153212 -730294960 -788109537 ...

output:

138293139269

result:

ok 1 number(s): "138293139269"

Test #22:

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

input:

5000 3318
-267084905 -709601392 524864687 180975267 196023405 335568366 -239177608 -961889019 503548441 -958343411 452714527 169247327 -187476252 464139800 -406187347 -568910494 914041602 682961812 -175237524 935504988 923648266 -618573813 155863255 -623311498 786326565 -491672666 581982804 28554297...

output:

334664774385

result:

ok 1 number(s): "334664774385"

Test #23:

score: 0
Accepted
time: 27ms
memory: 395992kb

input:

5000 4544
-157623255 485998689 827946155 340738526 872059837 -445129209 173135978 -759837074 -308299530 -570150715 -649147316 -397178364 -34299973 223629739 -105592861 569865299 588682647 -779621391 347497002 -862155131 -266146861 -175965957 -493242635 729218279 -481731998 14628607 392201450 -709347...

output:

147483170

result:

ok 1 number(s): "147483170"

Test #24:

score: 0
Accepted
time: 49ms
memory: 396156kb

input:

5000 3267
-48161604 -262395987 499623843 -426872857 506627071 628318980 -107094348 -631414056 -39421690 -181958018 255645521 625109402 -544687207 -983119678 436402157 202223884 -894727474 949909898 224789187 -788805273 -272208968 -101954320 462025795 -835125060 -808541213 -906180770 243889294 501748...

output:

1125371312071

result:

ok 1 number(s): "1125371312071"

Test #25:

score: 0
Accepted
time: 19ms
memory: 396036kb

input:

5000 1172
-307296174 38793284 -97672602 218039896 772598086 442912531 114681646 -839427528 844172780 793765323 -788514799 -189476927 -391510929 -447642325 -472244160 -203178689 -569368519 -341536768 -397048665 -715455416 -614707564 -954313757 94372465 -867402914 -503946647 -797732931 -759140650 -294...

output:

-53798044

result:

ok 1 number(s): "-53798044"

Test #26:

score: 0
Accepted
time: 48ms
memory: 396180kb

input:

5000 2536
197834523 -815190583 -695721363 304174227 743601809 -626102302 -48640016 -711004511 -943891160 331943698 -689980296 417407964 606930870 -912164973 -803053455 -835537275 949042273 143229055 -979373560 -347138267 -325802379 -175269411 -431751845 973309695 -904384790 984252385 -200763077 -717...

output:

730343886677

result:

ok 1 number(s): "730343886677"

Test #27:

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

input:

5000 85
204032807 813198405 619642255 92925039 75476025 37364175 991450863 512727934 396484319 852466498 45580848 477751963 249046764 925352677 961057715 324262430 575354121 334347699 -635219752 331280860 621515355 248444589 856322005 120152365 531808072 636457464 888297966 202551261 626651445 14171...

output:

865847614848

result:

ok 1 number(s): "865847614848"

Test #28:

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

input:

5000 1483
94571157 958191923 291319943 179059370 341447040 146925017 925409233 15708697 127606480 759241093 -242013637 705683000 95870486 389875323 660463229 -30249943 955027875 431007278 807479229 962963712 332610170 100804025 -193701384 521026438 563649995 -454380698 403549321 994951995 715967070 ...

output:

1889315415424

result:

ok 1 number(s): "1889315415424"

Test #29:

score: 0
Accepted
time: 31ms
memory: 395988kb

input:

5000 4916
353705726 439621928 594401411 -970226409 607418055 -961518569 932996531 592318389 932357570 371048397 479915623 933614038 311290428 149365262 991272525 662608529 629668920 896263077 684771415 184581145 338672277 26792388 531080763 626933220 259055429 50965567 255237164 123789216 510315403 ...

output:

942487558

result:

ok 1 number(s): "942487558"

Test #30:

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

input:

5000 3342
-244244075 510986518 897482879 56360739 578421778 439675631 161922192 95299152 32075949 982855701 381381120 497981563 158114149 908855201 27114527 663563333 640746454 -992922656 -562063601 111231288 681170872 584184533 794831215 659211073 585864643 237485021 65455811 916189950 936067517 -7...

output:

2028124930438

result:

ok 1 number(s): "2028124930438"

Test #31:

score: 0
Accepted
time: 20ms
memory: 396348kb

input:

5000 3152
503378645 992416524 569160567 847527779 918021721 254269182 -800913271 966876136 468230819 594663005 282846617 725912600 -668501383 78410556 62956530 295921918 -315387499 794614943 -439355787 37881431 392265687 510172896 132210594 765117854 -986302786 -129037182 917143656 708590683 7304158...

output:

135117521

result:

ok 1 number(s): "135117521"

Test #32:

score: 0
Accepted
time: 52ms
memory: 396184kb

input:

5000 2465
393916994 768813822 -167209326 -638694818 183992735 732426245 103467860 469856899 567949200 911503017 815715895 953843638 515325105 837900496 762362045 296876723 990028545 554838032 611615264 -964531575 29731574 362532332 174622681 871024635 386740928 651993125 432395011 132395196 15616796...

output:

1929244709161

result:

ok 1 number(s): "1929244709161"

Test #33:

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

input:

5000 4511
-680193012 -167922519 -582059801 -699846129 -643779541 -250197761 109545561 -40135481 213458616 -669763800 -174455383 267472505 -216167549 -289851115 -325503513 -64487896 -988457894 -943921821 -197505684 -869021941 -239829226 -861677748 -108652949 -229103454 -81746588 -819408658 -790002134...

output:

-15591200

result:

ok 1 number(s): "-15591200"

Test #34:

score: 0
Accepted
time: 51ms
memory: 396412kb

input:

5000 3079
-939327581 -649352526 885141269 -196045876 -909750556 -433387532 -412100151 -543116245 -649613486 -207942175 -75920880 -495403543 -62991271 -754373763 -656312808 -991813774 -663098939 40581399 74797870 795672084 -245891333 -714037183 -740999621 -335010235 -482184731 -342364600 -936657270 -...

output:

-54819889

result:

ok 1 number(s): "-54819889"

Test #35:

score: 0
Accepted
time: 19ms
memory: 396148kb

input:

5000 2463
-829865931 -425749823 -188222736 -282180207 -175721570 -247981083 -51091229 414693228 749331866 -819749480 -608790158 -354738360 -278411212 -513863701 -355718322 -992768579 -42772692 -432208269 -247057348 -722322227 -588389929 -640025547 -78378999 -440917017 -808993946 -233916761 451908625...

output:

215965591

result:

ok 1 number(s): "215965591"

Test #36:

score: 0
Accepted
time: 60ms
memory: 396084kb

input:

5000 2280
-720404280 -570743341 -859900425 -73347246 -146725293 -431170854 -985049600 -917673992 -554082955 136589492 -510255655 -582669397 -125234934 -978386349 391560326 -993723384 -717413738 -233900556 -829382243 -354005078 -594452036 -197417690 415758379 -178227578 -504399379 -125468923 -5985637...

output:

229700371570

result:

ok 1 number(s): "229700371570"

Test #37:

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

input:

5000 3486
-979538850 -347140638 -457949184 -159481576 -117729016 -540731697 -287604189 -789250975 -285205116 -748396796 -411721152 -515633143 -635622168 -737876287 -722369621 -626081969 -728491272 -699156355 -1641720 -575622513 -305546851 -418373346 -753137758 -579101651 -536241302 -311988377 -81884...

output:

-96187748

result:

ok 1 number(s): "-96187748"

Test #38:

score: 0
Accepted
time: 43ms
memory: 396168kb

input:

5000 2788
-870077199 -123537936 -761030653 -950648616 752296251 -355325248 -926595268 -660827958 -384923496 -360204100 -944590430 -743564180 -482445889 -202398934 -53178915 -332069482 -698099609 -500848642 -173901197 -502272656 -943012738 -680798199 -16888209 -979975725 -231646736 -539977027 -965502...

output:

74528548316

result:

ok 1 number(s): "74528548316"

Test #39:

score: 0
Accepted
time: 24ms
memory: 396028kb

input:

5000 1682
-4455182 -269461091 842800653 749260809 -440369550 707848190 118172837 -770940750 -111226481 -465805828 204144460 -881027034 129352520 -220834163 -916712230 -279368744 123178121 -663401171 -951610003 -526419245 851463619 -882405000 561083211 903676104 552033979 501480250 -678987660 -164698...

output:

1371080322

result:

ok 1 number(s): "1371080322"

Test #40:

score: 0
Accepted
time: 64ms
memory: 396276kb

input:

5000 2481
-894993532 750891097 440849412 245460556 -485002200 -596070669 -125760135 -273921513 -842348642 -77613131 737013738 108958071 639739754 -390389519 -247521524 911727330 797819167 760060750 -197498408 -453069388 -562558434 -144829852 -193429881 -9582884 878843194 -393032411 -899271724 588502...

output:

1889034274

result:

ok 1 number(s): "1889034274"

Test #41:

score: 0
Accepted
time: 31ms
memory: 396068kb

input:

5000 2404
-785531881 -527288395 743930881 -700191107 -750973215 705631512 59718505 -145498496 647099731 320824216 -638479235 -336889108 486563476 -149879458 578330819 912682135 -103863993 -561753037 74790594 -379719531 -200024321 -365785508 530809261 746893447 574248628 579551865 45926858 380903462 ...

output:

271818313

result:

ok 1 number(s): "271818313"

Test #42:

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

input:

5000 2196
-339633742 303685692 -415608568 786325438 -16944229 520225063 -993676876 -353511968 -746818111 932631520 539944732 901256634 701983418 909369397 -982769042 913636940 483537747 321976127 247050071 -306369673 -911119137 -218144943 868188641 852800228 606090550 176136734 561178214 -878336904 ...

output:

403095932392

result:

ok 1 number(s): "403095932392"

Test #43:

score: 0
Accepted
time: 31ms
memory: 396456kb

input:

5000 3873
-230172091 -448679210 -718690037 577492477 -987947953 -998382125 -1264173 -225088951 -182972980 544438824 -72814009 424154963 -548807139 373892044 -313578337 -251028233 158178792 -418635706 -419309549 233019816 -622213951 849166016 -542004508 -253674300 -301495984 -994059969 -707833350 302...

output:

854716648

result:

ok 1 number(s): "854716648"

Test #44:

score: 0
Accepted
time: 35ms
memory: 396232kb

input:

5000 3820
-415677733 225076507 -21771504 -663626808 -958951676 812975676 935222544 728069715 282691361 -156246127 974279507 -357118708 -59194372 133381982 644387632 -251983038 -832819838 220327993 1634443 864702668 259679838 701525451 174351179 990984863 -628305199 885612130 -223084705 -799574859 60...

output:

87782339600

result:

ok 1 number(s): "87782339600"

Test #45:

score: 0
Accepted
time: 40ms
memory: 396120kb

input:

5000 467
680680664 641228921 882137036 -810978887 564901249 181250287 298731558 895242476 574613524 686763693 529875589 625386392 995914834 378199270 536566836 678934611 506600268 948706447 318474144 -838057261 -322077703 454241155 810414973 335624019 559149007 723638239 926907030 583166114 55360583...

output:

25722420657

result:

ok 1 number(s): "25722420657"

Test #46:

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

input:

5000 3963
866186305 786222439 480185796 602145926 830872263 290811130 232689928 471852166 674331904 -593538288 726308378 558350138 137705846 137689209 235972350 -679889416 886274022 413962244 490733622 764707404 328139810 380229518 -147794352 -367901872 254554441 615190400 442158385 6970627 34795416...

output:

66266664936

result:

ok 1 number(s): "66266664936"

Test #47:

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

input:

5000 658
125320874 562619736 151863483 688280257 465439497 179033609 240277226 269800221 110486773 205345592 332806583 712652247 353125788 307244564 -566781645 312248001 855882359 -215654531 368025807 986324839 670638405 232588954 485173731 473808654 581363656 506742562 293846229 -799371361 47873899...

output:

998557151

result:

ok 1 number(s): "998557151"

Test #48:

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

input:

5000 114
15859223 339017034 749912244 479447296 141475928 288594452 174235596 141377204 210205154 817152896 865675861 645615992 494916802 -66734503 897590940 -313202806 -866959893 312314110 613914213 618007690 676700512 158577317 822553111 579715435 276769090 29698503 104064875 591772094 568054615 9...

output:

749346544294

result:

ok 1 number(s): "749346544294"

Test #49:

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

input:

5000 4525
906397574 115414331 52993711 270614334 407446943 103188003 813226675 349390676 -14956242 60363980 62108649 168514321 415369451 -826224443 302029163 314157611 541600938 777569909 491206399 544657833 19199107 715969462 791336270 685622216 677207233 921250666 955752720 720609316 362402948 147...

output:

785450831

result:

ok 1 number(s): "785450831"

Test #50:

score: 0
Accepted
time: 51ms
memory: 396172kb

input:

5000 4164
165532142 596844338 724671400 356748665 673417958 581345065 115781264 220967659 746078404 377203993 300010635 101478066 557160465 290747089 632838458 651548905 921274692 874229488 663465877 -471307976 25261214 936925118 423682941 422932778 4016446 107770118 471004075 513010049 788155062 66...

output:

471474903765

result:

ok 1 number(s): "471474903765"

Test #51:

score: 0
Accepted
time: 24ms
memory: 396072kb

input:

5000 2486
-156840868 -995953036 -770925654 -122932684 -133204764 -467712802 121858965 -717617315 -391587820 -135464775 -658750124 -46510715 -594439398 -742697710 -195979925 -714127369 -919704041 -558280567 -880760078 -375798342 -235358866 -67474312 -357713209 -444575108 -772651035 -611622141 -828611...

output:

1046842074

result:

ok 1 number(s): "1046842074"

Test #52:

score: 0
Accepted
time: 51ms
memory: 396404kb

input:

5000 817
-342346509 -772350334 -442603341 -914099724 -399175778 -282306353 -719380847 -589194298 -827742690 -747272080 -560215621 -274441752 -104826631 -502187648 -526789221 -715082174 -299377794 -654940146 758052263 -302448485 -577857462 -993462677 -695092588 -550481890 -99460249 -798141594 -975266...

output:

-9751739

result:

ok 1 number(s): "-9751739"

Test #53:

score: 0
Accepted
time: 44ms
memory: 396152kb

input:

5000 3967
-601481079 -253780339 -745684810 -705266763 -370179501 -391867196 -358371925 -797207769 -927461071 -654046675 -388052190 -502372789 -951650354 -966710296 -226194735 -347440759 -268986131 -751599725 -930311741 -229098628 583919569 -845822113 -32471967 -287792451 -794865684 -394726464 -49051...

output:

-539657775

result:

ok 1 number(s): "-539657775"

Test #54:

score: 0
Accepted
time: 49ms
memory: 396064kb

input:

5000 3964
-492019428 -325144928 -48766277 -791401094 -4746735 -575056966 -292330296 -668784752 732212159 -265853979 -994550396 -435336535 -462037586 431232942 -262036738 -53428272 -648659886 -216855523 -512636635 -155748771 295014384 771810476 369851347 -393699232 -531740315 -212649697 -637172825 -7...

output:

84388478058

result:

ok 1 number(s): "84388478058"

Test #55:

score: 0
Accepted
time: 19ms
memory: 396152kb

input:

5000 3838
-751153998 -175171154 -720443966 582568133 -975750459 -389650517 -594884886 -171765515 -831930540 -214097771 -896015893 -663267572 -13894016 -895755590 -297878741 54383077 -954704712 -18547810 -684896113 -377366205 932480272 329202620 -707230726 -794573305 -227145749 104201859 -857456888 -...

output:

-28638922

result:

ok 1 number(s): "-28638922"

Test #56:

score: 0
Accepted
time: 47ms
memory: 396412kb

input:

5000 4180
-641692347 -951568452 -23525433 -668702464 -946754182 572840288 -233875964 -43342498 -563052701 825905076 -428885170 -522602389 -524281250 -655245528 -628688037 -981708955 -334378465 -115207389 -857155591 -304016348 -643575086 -181562055 -44610105 -531883867 922551184 -290721313 -299079315...

output:

416861820

result:

ok 1 number(s): "416861820"

Test #57:

score: 0
Accepted
time: 35ms
memory: 396012kb

input:

5000 4258
-595799170 322886547 -890292815 -799026685 -647409334 -266815657 741811293 655275712 -684712076 -146846060 -522539259 -983476533 -886215319 -35036082 -36360226 -177877150 -368645647 941958941 -719148402 286865833 607850076 851538818 -324826195 791273670 -236431575 -685103060 482333828 7773...

output:

-4529246

result:

ok 1 number(s): "-4529246"

Test #58:

score: 0
Accepted
time: 144ms
memory: 396408kb

input:

5000 1452
-486337520 -99283845 -561970502 885161016 -913380349 -450005428 -380802371 158256475 415834237 758653365 424004756 -547844058 -396602551 -794526021 367169521 178831955 -748319401 -743651228 891407880 213515976 -950348672 777527181 293609354 897180452 -636869718 576655222 -923956256 -569730...

output:

327902719316

result:

ok 1 number(s): "327902719316"

Test #59:

score: 0
Accepted
time: 40ms
memory: 396024kb

input:

5000 2670
-745472089 170648434 -865051970 971295347 -884384072 559566271 683356961 29833458 -220585326 370460669 -956874034 70742386 -243426273 -554015960 66575036 516223249 422960446 840310807 768700065 -140166119 -956410779 629886617 925956026 -634491013 963678933 -99611164 -439207611 698567943 -5...

output:

-2303865

result:

ok 1 number(s): "-2303865"

Test #60:

score: -100
Wrong Answer
time: 97ms
memory: 396216kb

input:

5000 147
-636010438 -652078441 168133438 -467495094 -855387794 -742756042 -617315331 237846930 -320303706 318704461 858339531 -3706131 458846215 -18538606 -397384331 517178054 802634200 -10599313 -14588470 -698220043 -667505594 187278761 -263335405 740397794 659084367 -991163326 -290895455 -49096867...

output:

849565857053

result:

wrong answer 1st numbers differ - expected: '853565744482', found: '849565857053'