QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#808853#9184. Team Codingkkkgjyismine4100 ✓105ms27760kbC++202.0kb2024-12-11 08:30:462024-12-11 08:30:52

Judging History

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

  • [2024-12-11 08:30:52]
  • 评测
  • 测评结果:100
  • 用时:105ms
  • 内存:27760kb
  • [2024-12-11 08:30:46]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define N 100005
#define B 350
#define pb push_back
int *f[N],ff[N<<1],*ch=ff,son[N],len[N];
int in[N],out[N],dep[N],col[N],tt,fl[N],n,k,ret[N],ret1[N],ct[N];
vector<int>rd[N],cl[N];int cl1[N];
bool cmp(int a,int b){return dep[a]>dep[b];}
void dfs(int u){
	in[u]=out[u]=++tt;
	son[u]=-1;len[u]=0;
	for(int v:rd[u]){
		dep[v]=dep[u]+1,dfs(v),out[u]=out[v];
		if(len[u]<len[v]+1)len[u]=len[v]+1,son[u]=v;
    }if(son[u]!=-1)fl[son[u]]=1;
}
void dfs1(int u){
	for(int v:rd[u]){if(v==son[u])f[v]=f[u]+1;dfs1(v);}++f[u][0];
	for(int v:rd[u]){
		if(v==son[u])continue;
		for(int j=0;j<=len[v];++j)f[u][j+1]+=f[v][j];
    }
    if(cl1[col[u]]<=B){
    	for(int v:cl[col[u]]){
    		if(in[v]>=in[u]&&in[v]<=out[u])++ret1[u];
    		if(dep[v]-dep[u]<=len[u])ret[u]+=(ct[dep[v]]<f[u][dep[v]-dep[u]]),++ct[dep[v]];
    		if(v==u)break;
		}
		for(int v:cl[col[u]]){ct[dep[v]]=0;if(v==u)break;}
	}
}
int ss[N],ss1[N],ct1[N];
void dfs2(int u,int cc){
	ss1[u]=(col[u]==cc),ss[u]=0;
	for(int v:rd[u])dfs2(v,cc),ss1[u]+=ss1[v];
	if(son[u]>0)ss[u]=ss[son[u]];
	ss[u]+=(f[u][0]+1<=ct1[dep[u]]);
	f[u][0]=min(ct1[dep[u]],f[u][0]+1);
	for(int v:rd[u]){
		if(v==son[u])continue;
		for(int j=0;j<=len[v];++j){
			ss[u]-=f[u][j+1];
			f[u][j+1]=min(f[u][j+1]+f[v][j],ct1[dep[u]+j+1]);
			ss[u]+=f[u][j+1];
		}
    }
	if(col[u]==cc)ret[u]=ss[u],ret1[u]=ss1[u];
}
int main(){
	ios::sync_with_stdio(0),cin>>n>>k;
	for(int i=1;i<=n;++i)cin>>col[i],++col[i],cl[col[i]].pb(i),++cl1[col[i]];
	for(int i=2,x;i<=n;++i)cin>>x,++x,rd[x].pb(i);dfs(1);
	for(int i=1;i<=n;++i)if(!fl[i])f[i]=ch,ch+=len[i]+1;
	for(int i=1;i<=k;++i)sort(cl[i].begin(),cl[i].end(),cmp);
	dfs1(1);
	for(int cc=1;cc<=k;++cc){
		if(cl1[cc]<=B)continue;
		for(int i=0;i<=n+1;++i)ff[i]=ct1[i]=0;
		for(int v:cl[cc])++ct1[dep[v]];
		dfs2(1,cc);
	}
	int mx=-1,mx1=0;
	for(int i=1;i<=n;++i){
		if(mx<ret[i])mx=ret[i],mx1=ret[i]-ret1[i];
		else if(mx==ret[i]&&mx1>ret[i]-ret1[i])mx1=ret[i]-ret1[i];
	}cout<<mx<<" "<<mx1;
	return 0;
}

詳細信息

Subtask #1:

score: 12
Accepted

Test #1:

score: 12
Accepted
time: 2ms
memory: 9776kb

input:

1 1
0

output:

1 0

result:

ok single line: '1 0'

Test #2:

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

input:

5 2
0 1 0 0 0
0
1
2
3

output:

4 0

result:

ok single line: '4 0'

Test #3:

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

input:

10 9
6 5 6 2 5 4 5 3 4 1
0
1
2
3
4
5
6
7
8

output:

3 0

result:

ok single line: '3 0'

Test #4:

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

input:

15 8
3 6 7 6 7 6 6 0 6 7 3 6 2 3 3
0
1
2
3
4
5
6
7
8
9
10
11
12
13

output:

6 0

result:

ok single line: '6 0'

Test #5:

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

input:

7 3
1 1 1 2 1 0 1
0
1
2
3
4
5

output:

5 0

result:

ok single line: '5 0'

Test #6:

score: 12
Accepted
time: 1ms
memory: 9860kb

input:

8 6
1 4 0 1 3 0 4 5
0
1
2
3
4
5
6

output:

2 0

result:

ok single line: '2 0'

Test #7:

score: 12
Accepted
time: 1ms
memory: 7720kb

input:

100 97
73 42 17 20 20 71 6 52 18 93 34 27 96 35 77 27 46 62 23 83 12 13 91 61 82 0 59 82 6 67 24 37 4 61 2 6 31 12 21 37 47 39 44 85 92 16 66 39 48 69 57 62 75 7 87 68 89 44 77 69 12 6 19 31 30 2 14 90 30 37 67 5 88 53 59 3 1 45 75 82 59 27 51 0 85 65 57 75 74 53 35 44 87 86 77 52 35 23 87 87
0
1
2
...

output:

4 0

result:

ok single line: '4 0'

Test #8:

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

input:

2000 28
13 0 11 21 0 3 7 0 2 10 25 17 13 21 19 12 9 17 21 12 12 17 9 2 21 11 0 13 9 4 6 18 4 14 22 26 20 24 18 5 0 27 13 15 4 8 9 27 17 24 13 4 27 3 6 11 24 18 10 5 22 8 7 4 26 22 18 27 1 0 1 21 23 1 10 2 1 21 7 25 24 21 25 23 22 0 14 5 3 6 19 8 7 4 7 27 27 19 26 18 17 3 1 12 8 1 10 18 22 23 25 14 2...

output:

85 0

result:

ok single line: '85 0'

Test #9:

score: 12
Accepted
time: 24ms
memory: 25204kb

input:

100000 59066
10203 30163 14221 32641 57632 52742 51576 33938 17167 56268 10461 37834 58393 19522 10361 4859 50498 54209 40282 44610 7141 54240 58622 15568 57813 20977 23646 51685 16859 23152 37761 20080 6279 48735 39054 5181 35803 38656 7011 54044 4665 29269 39955 44267 6927 1328 56776 24684 2653 10...

output:

10 0

result:

ok single line: '10 0'

Test #10:

score: 12
Accepted
time: 2ms
memory: 7752kb

input:

100 2
0 1 0 0 1 0 0 1 1 0 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 1 1 1 0 0 0 0 1 1 0 1 0 1 1 0 1 1 1 0 1 0 1 0 0 1 1 1 0 0 0 1 1 0 1 1 1 0 0 1 1 0 1 0 0 0 1 1 0 1 1 0 1 1 1 1 0 0 0 1 1 0 0 0 1 1 0 1 0 0 0 0 1 1 0 1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34...

output:

50 0

result:

ok single line: '50 0'

Test #11:

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

input:

2000 2
0 0 1 1 0 0 0 0 0 0 1 1 1 1 0 1 1 0 1 1 0 0 1 0 1 1 0 0 1 1 0 0 0 1 0 0 1 1 0 0 1 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 1 1 0 1 0 1 1 1 1 0 0 0 0 0 1 0 0 0 1 1 1 0 1 0 0 0 1 1 1 0 1 0 1 1 1 1 0 0 1 1 1 0 0 0 1 1 0 1 1 1 1 0 1 1 1 1 1 0 0 1 1 1 0 1 0 1 1 0 1 0 0 0 0 1 1 0 0 0 0 0 0 1 0...

output:

1001 0

result:

ok single line: '1001 0'

Test #12:

score: 12
Accepted
time: 29ms
memory: 23312kb

input:

100000 2
0 0 1 0 0 0 1 0 0 0 0 1 1 1 1 0 0 0 0 0 1 0 1 0 1 0 1 1 0 1 0 1 1 0 1 1 1 0 0 1 0 0 1 1 0 0 1 1 0 1 1 0 1 0 1 1 0 1 1 1 1 0 0 1 1 1 1 1 1 1 0 1 0 0 1 0 0 1 1 1 1 1 1 0 0 1 0 1 1 0 1 1 0 0 1 0 0 0 0 0 1 1 0 1 0 0 0 1 1 0 0 1 1 0 1 1 1 0 1 1 1 1 0 0 1 1 1 0 1 1 0 1 1 1 1 1 0 1 1 0 0 1 0 1 0 0...

output:

50198 0

result:

ok single line: '50198 0'

Test #13:

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

input:

100 100
14 93 75 59 44 2 61 56 89 75 70 53 50 78 16 1 48 32 52 21 84 12 75 52 39 89 88 29 71 69 18 0 19 20 66 23 55 99 42 63 46 2 93 23 40 13 64 32 51 47 34 13 95 48 23 55 20 21 87 46 62 7 69 98 66 77 66 16 85 70 2 51 9 9 37 89 85 72 59 13 14 69 4 78 56 84 63 40 35 90 93 44 66 32 25 80 93 99 40 39
0...

output:

4 0

result:

ok single line: '4 0'

Test #14:

score: 12
Accepted
time: 2ms
memory: 10176kb

input:

2000 2000
68 392 1223 140 162 1107 45 1894 1544 255 840 1756 173 1277 1932 1230 1774 932 1637 935 1554 1296 917 158 707 1350 297 1763 1374 1778 637 1079 726 1514 485 678 288 1595 1529 296 414 1803 816 1419 962 1234 521 277 1353 1679 1472 249 1083 1539 442 1925 442 114 116 790 1246 649 15 145 1622 36...

output:

6 0

result:

ok single line: '6 0'

Test #15:

score: 12
Accepted
time: 27ms
memory: 27116kb

input:

100000 100000
41728 93320 38571 44676 59528 37978 81336 71690 19433 62851 10920 32382 57235 11051 54769 96948 26321 8339 26066 61016 79074 40324 13106 94743 16700 60377 60008 60349 77853 65660 4887 16582 91933 4573 43258 30974 68341 21985 25073 6706 28676 32064 29269 78970 28685 53456 23597 67768 65...

output:

8 0

result:

ok single line: '8 0'

Test #16:

score: 12
Accepted
time: 1ms
memory: 7748kb

input:

5 3
0 1 2 2 1
0
1
2
3

output:

2 0

result:

ok single line: '2 0'

Subtask #2:

score: 19
Accepted

Test #17:

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

input:

1 1
0

output:

1 0

result:

ok single line: '1 0'

Test #18:

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

input:

5 2
0 1 0 0 0
0
1
2
3

output:

4 0

result:

ok single line: '4 0'

Test #19:

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

input:

100 2
0 1 0 0 1 0 0 1 1 0 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 1 1 1 0 0 0 0 1 1 0 1 0 1 1 0 1 1 1 0 1 0 1 0 0 1 1 1 0 0 0 1 1 0 1 1 1 0 0 1 1 0 1 0 0 0 1 1 0 1 1 0 1 1 1 1 0 0 0 1 1 0 0 0 1 1 0 1 0 0 0 0 1 1 0 1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34...

output:

50 0

result:

ok single line: '50 0'

Test #20:

score: 19
Accepted
time: 2ms
memory: 8132kb

input:

2000 2
0 0 1 1 0 0 0 0 0 0 1 1 1 1 0 1 1 0 1 1 0 0 1 0 1 1 0 0 1 1 0 0 0 1 0 0 1 1 0 0 1 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 1 1 0 1 0 1 1 1 1 0 0 0 0 0 1 0 0 0 1 1 1 0 1 0 0 0 1 1 1 0 1 0 1 1 1 1 0 0 1 1 1 0 0 0 1 1 0 1 1 1 1 0 1 1 1 1 1 0 0 1 1 1 0 1 0 1 1 0 1 0 0 0 0 1 1 0 0 0 0 0 0 1 0...

output:

1001 0

result:

ok single line: '1001 0'

Test #21:

score: 19
Accepted
time: 22ms
memory: 22916kb

input:

100000 2
0 0 1 0 0 0 1 0 0 0 0 1 1 1 1 0 0 0 0 0 1 0 1 0 1 0 1 1 0 1 0 1 1 0 1 1 1 0 0 1 0 0 1 1 0 0 1 1 0 1 1 0 1 0 1 1 0 1 1 1 1 0 0 1 1 1 1 1 1 1 0 1 0 0 1 0 0 1 1 1 1 1 1 0 0 1 0 1 1 0 1 1 0 0 1 0 0 0 0 0 1 1 0 1 0 0 0 1 1 0 0 1 1 0 1 1 1 0 1 1 1 1 0 0 1 1 1 0 1 1 0 1 1 1 1 1 0 1 1 0 0 1 0 1 0 0...

output:

50198 0

result:

ok single line: '50198 0'

Test #22:

score: 19
Accepted
time: 1ms
memory: 7708kb

input:

99 2
0 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
65
53
0
0
41
0
59
26
87
78
62
23
52
0
97
0
0
90
0
4
77
55
0
73
45
0
19
92
32
0
0
0
82
48
60
54
72...

output:

2 0

result:

ok single line: '2 0'

Test #23:

score: 19
Accepted
time: 2ms
memory: 9908kb

input:

1999 2
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

2 0

result:

ok single line: '2 0'

Test #24:

score: 19
Accepted
time: 29ms
memory: 14092kb

input:

99999 2
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

2 0

result:

ok single line: '2 0'

Test #25:

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

input:

100 2
1 1 1 0 0 1 0 1 1 0 1 0 0 0 1 1 0 1 0 0 1 0 1 0 0 0 1 1 1 1 1 0 1 0 1 1 0 1 1 0 0 1 0 1 0 1 0 0 0 1 0 1 0 0 1 1 0 0 0 1 1 0 1 0 1 1 0 1 1 1 1 0 1 0 0 1 0 0 1 0 0 1 1 0 1 0 1 0 0 0 1 0 0 1 1 1 1 0 1 0
68
34
15
37
60
98
14
80
81
1
94
60
1
45
55
5
29
93
55
41
54
54
96
70
2
32
62
94
15
37
41
90
68...

output:

51 0

result:

ok single line: '51 0'

Test #26:

score: 19
Accepted
time: 2ms
memory: 7968kb

input:

2000 2
1 0 1 0 0 1 0 0 0 0 1 1 1 1 1 1 0 1 0 1 1 0 1 1 0 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 0 0 0 1 1 1 1 1 0 0 1 0 1 1 1 1 1 0 0 1 1 0 1 0 0 1 1 0 1 0 1 0 0 1 1 1 0 0 1 0 1 0 1 1 1 1 0 1 1 0 1 1 1 1 0 1 0 1 1 1 1 1 1 0 0 0 1 1 1 0 1 0 1 1 0 1 0 0 1 1 1 1 0 0 1 0 0 0 0 0 0 0 1 1 1 1 0 1 1 0 0 0 1 1 1 1 0...

output:

1001 0

result:

ok single line: '1001 0'

Test #27:

score: 19
Accepted
time: 46ms
memory: 17764kb

input:

100000 2
0 0 1 1 1 0 1 1 1 1 0 1 0 0 0 0 0 1 0 1 0 1 0 1 0 0 1 0 1 1 1 0 0 1 1 0 0 0 0 0 1 0 0 1 0 1 0 1 0 1 0 0 0 0 1 1 1 1 0 1 0 1 1 1 0 0 0 1 0 0 1 1 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 1 0 1 1 0 0 1 0 1 0 0 1 1 1 0 0 0 1 0 0 1 0 1 0 0 0 1 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 1 0 1 1 1 1 1 0 0 0 0 0 0 0...

output:

50001 0

result:

ok single line: '50001 0'

Test #28:

score: 19
Accepted
time: 10ms
memory: 11560kb

input:

100000 2
0 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:

7 2

result:

ok single line: '7 2'

Test #29:

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

input:

10 2
1 1 1 1 0 1 1 1 1 0
8
8
8
3
9
0
9
0
0

output:

8 0

result:

ok single line: '8 0'

Test #30:

score: 19
Accepted
time: 1ms
memory: 7804kb

input:

100 2
0 0 1 1 1 1 1 0 1 0 0 0 0 0 0 0 1 1 1 0 1 1 1 1 0 0 1 1 1 0 0 1 0 0 1 0 0 0 0 0 0 1 1 1 1 0 0 1 1 0 1 1 1 0 1 1 0 1 1 0 0 0 0 1 0 0 1 0 0 1 1 0 1 1 1 0 0 1 0 1 1 1 1 0 0 1 1 1 0 1 1 1 1 0 1 1 0 1 0 1
27
11
39
3
90
87
91
49
39
95
91
49
89
15
64
27
85
38
43
86
51
28
51
64
54
28
69
87
4
54
27
24
...

output:

46 0

result:

ok single line: '46 0'

Test #31:

score: 19
Accepted
time: 49ms
memory: 13868kb

input:

100000 2
1 0 0 0 0 1 1 1 1 0 0 1 0 0 1 0 1 1 0 1 1 1 1 0 0 0 0 0 1 0 0 0 1 0 1 1 0 1 0 1 0 1 0 0 0 0 1 1 0 0 0 0 1 0 0 1 1 1 1 0 1 1 1 1 0 1 0 1 1 0 0 1 0 0 0 0 0 1 1 1 0 0 0 1 1 1 0 0 1 1 0 1 1 1 1 1 0 1 1 0 1 0 0 1 0 1 1 1 1 0 1 0 1 1 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 0 1 0 0 0 0 0...

output:

50040 0

result:

ok single line: '50040 0'

Test #32:

score: 19
Accepted
time: 42ms
memory: 13872kb

input:

100000 2
1 0 0 1 0 0 1 0 1 1 1 0 1 1 0 0 1 1 0 1 1 1 0 0 0 1 1 0 0 0 1 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 1 0 0 0 1 0 0 1 1 0 0 1 0 0 1 1 1 0 0 1 0 0 1 0 1 1 0 0 0 0 1 0 1 0 1 1 1 1 1 0 1 0 1 1 1 1 0 0 1 0 1 1 1 1 0 0 1 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 1 0 0 0 1 1 0 0 1 0 0 0 1 1 0...

output:

50006 0

result:

ok single line: '50006 0'

Test #33:

score: 19
Accepted
time: 1ms
memory: 7808kb

input:

100 2
1 1 0 1 0 0 1 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 1 1 1 1 0 0 0 0 0 1 1 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 1 0 0 1 1 0 0 0 0 0 0 1
47
84
42
64
90
84
0
84
7
56
35
59
80
98
16
73
56
7
47
33
6
16
24
70
97
3
22
8
19
18
97
7
84
79...

output:

47 12

result:

ok single line: '47 12'

Test #34:

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

input:

2000 2
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 0 1 1 1 0 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1127 147

result:

ok single line: '1127 147'

Test #35:

score: 19
Accepted
time: 37ms
memory: 13944kb

input:

100000 2
1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

39105 5115

result:

ok single line: '39105 5115'

Test #36:

score: 19
Accepted
time: 43ms
memory: 14064kb

input:

100000 2
0 0 0 1 0 1 1 1 1 0 0 1 1 1 0 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 0 0 1 0 1 1 0 1 1 1 1 1 1 0 1 1 0 1 0 1 1 1 1 1 1...

output:

61321 12576

result:

ok single line: '61321 12576'

Test #37:

score: 19
Accepted
time: 36ms
memory: 13928kb

input:

100000 2
0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 1 0 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1...

output:

75885 8789

result:

ok single line: '75885 8789'

Test #38:

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

input:

4 2
0 1 0 0
0
0
1

output:

3 0

result:

ok single line: '3 0'

Subtask #3:

score: 27
Accepted

Test #39:

score: 27
Accepted
time: 2ms
memory: 9864kb

input:

1 1
0

output:

1 0

result:

ok single line: '1 0'

Test #40:

score: 27
Accepted
time: 1ms
memory: 9776kb

input:

5 2
0 1 0 0 0
0
1
2
3

output:

4 0

result:

ok single line: '4 0'

Test #41:

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

input:

10 9
6 5 6 2 5 4 5 3 4 1
0
1
2
3
4
5
6
7
8

output:

3 0

result:

ok single line: '3 0'

Test #42:

score: 27
Accepted
time: 2ms
memory: 7700kb

input:

15 8
3 6 7 6 7 6 6 0 6 7 3 6 2 3 3
0
1
2
3
4
5
6
7
8
9
10
11
12
13

output:

6 0

result:

ok single line: '6 0'

Test #43:

score: 27
Accepted
time: 1ms
memory: 7820kb

input:

7 3
1 1 1 2 1 0 1
0
1
2
3
4
5

output:

5 0

result:

ok single line: '5 0'

Test #44:

score: 27
Accepted
time: 2ms
memory: 9740kb

input:

8 6
1 4 0 1 3 0 4 5
0
1
2
3
4
5
6

output:

2 0

result:

ok single line: '2 0'

Test #45:

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

input:

100 97
73 42 17 20 20 71 6 52 18 93 34 27 96 35 77 27 46 62 23 83 12 13 91 61 82 0 59 82 6 67 24 37 4 61 2 6 31 12 21 37 47 39 44 85 92 16 66 39 48 69 57 62 75 7 87 68 89 44 77 69 12 6 19 31 30 2 14 90 30 37 67 5 88 53 59 3 1 45 75 82 59 27 51 0 85 65 57 75 74 53 35 44 87 86 77 52 35 23 87 87
0
1
2
...

output:

4 0

result:

ok single line: '4 0'

Test #46:

score: 27
Accepted
time: 27ms
memory: 25148kb

input:

100000 59066
10203 30163 14221 32641 57632 52742 51576 33938 17167 56268 10461 37834 58393 19522 10361 4859 50498 54209 40282 44610 7141 54240 58622 15568 57813 20977 23646 51685 16859 23152 37761 20080 6279 48735 39054 5181 35803 38656 7011 54044 4665 29269 39955 44267 6927 1328 56776 24684 2653 10...

output:

10 0

result:

ok single line: '10 0'

Test #47:

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

input:

100 100
14 93 75 59 44 2 61 56 89 75 70 53 50 78 16 1 48 32 52 21 84 12 75 52 39 89 88 29 71 69 18 0 19 20 66 23 55 99 42 63 46 2 93 23 40 13 64 32 51 47 34 13 95 48 23 55 20 21 87 46 62 7 69 98 66 77 66 16 85 70 2 51 9 9 37 89 85 72 59 13 14 69 4 78 56 84 63 40 35 90 93 44 66 32 25 80 93 99 40 39
0...

output:

4 0

result:

ok single line: '4 0'

Test #48:

score: 27
Accepted
time: 2ms
memory: 10192kb

input:

2000 2000
68 392 1223 140 162 1107 45 1894 1544 255 840 1756 173 1277 1932 1230 1774 932 1637 935 1554 1296 917 158 707 1350 297 1763 1374 1778 637 1079 726 1514 485 678 288 1595 1529 296 414 1803 816 1419 962 1234 521 277 1353 1679 1472 249 1083 1539 442 1925 442 114 116 790 1246 649 15 145 1622 36...

output:

6 0

result:

ok single line: '6 0'

Test #49:

score: 27
Accepted
time: 22ms
memory: 27760kb

input:

100000 100000
41728 93320 38571 44676 59528 37978 81336 71690 19433 62851 10920 32382 57235 11051 54769 96948 26321 8339 26066 61016 79074 40324 13106 94743 16700 60377 60008 60349 77853 65660 4887 16582 91933 4573 43258 30974 68341 21985 25073 6706 28676 32064 29269 78970 28685 53456 23597 67768 65...

output:

8 0

result:

ok single line: '8 0'

Test #50:

score: 27
Accepted
time: 2ms
memory: 9836kb

input:

10 2
1 1 1 1 0 1 1 1 1 0
8
8
8
3
9
0
9
0
0

output:

8 0

result:

ok single line: '8 0'

Test #51:

score: 27
Accepted
time: 1ms
memory: 7752kb

input:

12 8
1 4 0 5 4 1 7 1 2 6 3 1
0
10
9
10
11
7
0
2
0
0
10

output:

4 0

result:

ok single line: '4 0'

Test #52:

score: 27
Accepted
time: 1ms
memory: 9868kb

input:

11 7
2 2 5 0 6 2 5 5 5 5 4
2
10
5
0
7
10
0
7
10
0

output:

3 0

result:

ok single line: '3 0'

Test #53:

score: 27
Accepted
time: 2ms
memory: 7916kb

input:

2000 1214
94 1026 161 676 277 317 994 521 763 1177 1070 228 1083 290 423 642 328 179 713 1180 730 234 70 170 1092 1198 796 819 119 488 743 526 1011 1010 1181 804 994 386 991 1027 739 266 218 1171 697 569 682 891 40 560 377 946 996 653 42 270 43 359 107 771 389 208 419 44 559 870 562 673 451 955 61 1...

output:

7 6

result:

ok single line: '7 6'

Test #54:

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

input:

2000 367
240 338 214 215 327 33 32 206 53 269 186 47 319 131 343 20 146 101 324 327 213 183 148 96 44 2 305 114 170 199 278 4 285 272 108 96 265 284 123 84 285 343 174 52 363 211 62 200 182 192 189 204 22 291 129 131 43 177 36 144 346 356 74 336 258 107 363 259 203 356 32 142 301 284 73 362 257 28 2...

output:

9 6

result:

ok single line: '9 6'

Test #55:

score: 27
Accepted
time: 2ms
memory: 7868kb

input:

2000 1709
1485 645 329 201 238 168 1571 1439 1324 326 889 1583 529 384 621 412 1318 1440 867 1455 944 1383 850 862 376 1565 747 631 1115 1358 676 1599 673 261 1461 1078 205 110 133 938 368 618 1097 771 1085 840 124 873 19 1692 653 1145 1347 225 380 1581 475 758 1190 645 1163 1529 862 423 292 1467 14...

output:

4 3

result:

ok single line: '4 3'

Test #56:

score: 27
Accepted
time: 44ms
memory: 16544kb

input:

100000 75391
6003 72241 28741 19704 62287 24690 41725 29510 57883 38477 33470 4992 35443 46446 51948 19117 63206 70119 59682 17977 17585 63767 27706 24382 5246 12260 21715 30157 71722 52898 17011 8901 11539 24958 24021 62637 49016 39312 43249 47312 34246 42988 54094 15067 35673 17443 54173 74045 177...

output:

5 4

result:

ok single line: '5 4'

Test #57:

score: 27
Accepted
time: 45ms
memory: 15840kb

input:

100000 49117
41499 634 5420 22557 37968 3746 45332 11341 478 17636 21492 12335 24063 6190 18849 15466 21965 4971 16528 23666 26722 12564 1621 44222 22252 1328 7231 47550 38290 41788 33437 31121 20010 18004 7984 36028 6592 19326 39515 8315 9147 23356 9582 7518 22805 24271 17382 1169 7811 24026 15104 ...

output:

6 3

result:

ok single line: '6 3'

Test #58:

score: 27
Accepted
time: 47ms
memory: 16588kb

input:

100000 12500
3351 6242 3439 6257 5667 2932 5195 5012 5862 59 6395 10258 11579 6284 8052 1326 2424 367 4808 11951 2511 3009 11535 363 1598 3821 5241 4749 4520 11867 9406 5969 10785 7052 12323 546 12447 4428 2601 4526 7179 5328 510 6179 1390 11793 10075 7987 11764 7577 11329 8480 303 3771 5525 10954 4...

output:

10 0

result:

ok single line: '10 0'

Test #59:

score: 27
Accepted
time: 38ms
memory: 13380kb

input:

100000 12500
1863 9353 1760 3692 12493 5739 7507 4213 8749 7520 1300 6286 11171 8248 12484 5693 2553 10863 683 6071 6332 8639 4169 6304 9237 10023 4036 2507 9564 1555 713 1308 1205 5730 3200 10588 8826 7249 10197 10061 8312 1477 222 8425 753 9367 5506 5340 6606 4781 12235 2460 6006 8719 5709 12076 2...

output:

10 8

result:

ok single line: '10 8'

Test #60:

score: 27
Accepted
time: 33ms
memory: 17020kb

input:

100000 96893
95051 72243 10063 60661 91889 47907 52292 43931 95258 20748 35404 2410 62255 24866 81818 47996 58452 41934 57010 14996 45631 14835 45612 82642 35070 16256 822 8752 18362 68818 59643 82399 90061 80210 30083 38874 59046 3585 10982 29084 82862 44312 66064 42244 15172 13194 59371 10555 7510...

output:

5 4

result:

ok single line: '5 4'

Test #61:

score: 27
Accepted
time: 50ms
memory: 21112kb

input:

100000 50001
0 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99...

output:

2 0

result:

ok single line: '2 0'

Test #62:

score: 27
Accepted
time: 51ms
memory: 18836kb

input:

99999 33336
15028 24699 11531 16033 15308 19476 1876 26665 10206 23562 2457 16515 27494 8224 20364 5708 23502 28651 18632 2605 30444 27706 24511 2402 29194 4277 11533 29989 10623 9573 29600 28753 30975 5802 22730 14558 18279 27181 22000 9237 15382 20303 31855 25528 15993 19556 4529 3241 14917 26152 ...

output:

2 1

result:

ok single line: '2 1'

Test #63:

score: 27
Accepted
time: 2ms
memory: 7916kb

input:

1998 669
546 478 393 533 544 272 556 644 418 224 101 256 640 356 503 299 319 13 256 422 107 502 137 364 553 141 383 20 629 111 83 415 107 226 576 634 473 508 429 191 479 270 492 608 534 622 329 10 56 192 603 148 198 125 140 266 449 437 385 169 275 182 306 391 21 231 453 99 518 252 82 371 599 231 129...

output:

2 1

result:

ok single line: '2 1'

Test #64:

score: 27
Accepted
time: 2ms
memory: 8024kb

input:

2000 1290
328 751 977 533 1230 32 440 804 902 68 1058 32 47 25 390 1177 943 977 1010 811 1031 59 942 394 331 57 814 683 547 589 33 1262 862 380 709 1127 430 749 888 749 813 43 844 606 590 980 70 868 708 337 1099 1079 1086 708 684 1279 1129 55 365 433 966 461 1184 263 1165 489 512 183 402 930 886 850...

output:

6 0

result:

ok single line: '6 0'

Test #65:

score: 27
Accepted
time: 2ms
memory: 7884kb

input:

2000 1371
1036 382 1132 1054 337 509 1027 490 1363 135 782 1204 136 976 1132 1299 683 611 1226 235 706 166 7 808 1310 1245 528 148 513 830 1033 883 1170 248 947 857 1000 864 1103 121 717 231 954 1261 1199 341 837 1101 1065 48 392 1117 1014 8 233 840 582 91 1073 405 251 44 1283 193 924 356 379 468 13...

output:

5 4

result:

ok single line: '5 4'

Test #66:

score: 27
Accepted
time: 2ms
memory: 8020kb

input:

2000 1911
1372 1087 544 1695 405 1466 1459 1528 1728 424 99 791 1717 788 1117 1652 627 1393 1432 1562 920 1406 744 61 1516 1758 439 762 1822 1640 1834 507 938 1658 1495 1533 425 510 1392 873 1370 1370 755 696 943 1709 1558 115 695 194 409 808 976 32 306 515 429 408 281 1532 702 1060 627 1289 598 600...

output:

4 2

result:

ok single line: '4 2'

Test #67:

score: 27
Accepted
time: 5ms
memory: 10716kb

input:

10000 9323
962 8383 6995 1036 4327 3860 3350 9071 1244 3604 2401 6242 5424 2967 2800 5578 1656 2138 5652 7348 5985 8430 2556 2437 6201 4804 5924 697 1270 877 5874 3419 4160 103 1008 6025 2894 3635 8788 8469 6474 7559 2906 4014 4519 6787 8724 4359 6203 2060 5922 3876 3026 6031 875 2248 6742 7236 4338...

output:

5 2

result:

ok single line: '5 2'

Test #68:

score: 27
Accepted
time: 39ms
memory: 16012kb

input:

100000 52420
26262 46221 25641 24296 987 11464 17938 10592 41066 9659 15503 38267 40116 21923 13900 5632 26410 32886 25879 50594 13791 50209 3481 3932 12821 29655 30937 15889 9008 5486 16266 51350 51993 11855 33156 35354 17563 38460 27422 41883 32313 17975 15432 41121 6075 1750 642 37390 6962 6646 4...

output:

8 7

result:

ok single line: '8 7'

Test #69:

score: 27
Accepted
time: 52ms
memory: 17500kb

input:

100000 90378
67239 25212 89662 59573 7454 57178 59461 26816 14645 63568 24161 7227 86746 38584 27486 40208 89126 4327 29837 8653 62071 42190 20598 35271 87322 37795 18292 34373 87872 886 50277 5101 75648 59283 88536 32969 10734 4199 3813 74956 73859 78583 64283 61149 53760 14608 45928 81377 51331 16...

output:

7 3

result:

ok single line: '7 3'

Test #70:

score: 27
Accepted
time: 54ms
memory: 19840kb

input:

100000 97326
3834 63201 65063 61863 28834 19701 96074 84029 35961 83262 87561 49943 38607 59670 63612 50459 74106 85100 44599 43239 62860 862 83576 89134 17431 95440 35750 21704 70568 76336 10132 36366 72266 23271 6664 7859 79197 10223 84254 67287 90473 49469 54174 52372 59500 89297 92122 43764 3476...

output:

9 0

result:

ok single line: '9 0'

Test #71:

score: 27
Accepted
time: 30ms
memory: 16048kb

input:

100000 78050
31469 58640 36595 28575 59252 3155 8187 60461 49864 39581 49504 57438 3706 51926 21777 77093 59307 20236 67491 3332 56597 25394 34811 71580 67844 25966 22307 3244 57386 59877 2267 58834 8993 37893 72864 18036 9520 44587 39438 50974 33153 5724 3842 12762 38045 67979 55814 32838 53535 190...

output:

6 5

result:

ok single line: '6 5'

Test #72:

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

input:

5 3
0 1 2 2 1
0
1
2
3

output:

2 0

result:

ok single line: '2 0'

Test #73:

score: 27
Accepted
time: 2ms
memory: 9740kb

input:

4 2
0 1 0 0
0
0
1

output:

3 0

result:

ok single line: '3 0'

Test #74:

score: 27
Accepted
time: 1ms
memory: 7764kb

input:

9 3
0 0 2 1 2 0 2 1 2
4
8
1
0
4
1
0
7

output:

4 2

result:

ok single line: '4 2'

Test #75:

score: 27
Accepted
time: 2ms
memory: 9804kb

input:

8 3
0 2 1 2 2 1 1 1
6
3
0
6
3
0
3

output:

3 2

result:

ok single line: '3 2'

Subtask #4:

score: 23
Accepted

Test #76:

score: 23
Accepted
time: 2ms
memory: 9748kb

input:

1 1
0

output:

1 0

result:

ok single line: '1 0'

Test #77:

score: 23
Accepted
time: 2ms
memory: 7752kb

input:

5 2
0 1 0 0 0
0
1
2
3

output:

4 0

result:

ok single line: '4 0'

Test #78:

score: 23
Accepted
time: 2ms
memory: 9836kb

input:

10 9
6 5 6 2 5 4 5 3 4 1
0
1
2
3
4
5
6
7
8

output:

3 0

result:

ok single line: '3 0'

Test #79:

score: 23
Accepted
time: 2ms
memory: 9860kb

input:

15 8
3 6 7 6 7 6 6 0 6 7 3 6 2 3 3
0
1
2
3
4
5
6
7
8
9
10
11
12
13

output:

6 0

result:

ok single line: '6 0'

Test #80:

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

input:

7 3
1 1 1 2 1 0 1
0
1
2
3
4
5

output:

5 0

result:

ok single line: '5 0'

Test #81:

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

input:

8 6
1 4 0 1 3 0 4 5
0
1
2
3
4
5
6

output:

2 0

result:

ok single line: '2 0'

Test #82:

score: 23
Accepted
time: 2ms
memory: 7776kb

input:

100 97
73 42 17 20 20 71 6 52 18 93 34 27 96 35 77 27 46 62 23 83 12 13 91 61 82 0 59 82 6 67 24 37 4 61 2 6 31 12 21 37 47 39 44 85 92 16 66 39 48 69 57 62 75 7 87 68 89 44 77 69 12 6 19 31 30 2 14 90 30 37 67 5 88 53 59 3 1 45 75 82 59 27 51 0 85 65 57 75 74 53 35 44 87 86 77 52 35 23 87 87
0
1
2
...

output:

4 0

result:

ok single line: '4 0'

Test #83:

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

input:

2000 28
13 0 11 21 0 3 7 0 2 10 25 17 13 21 19 12 9 17 21 12 12 17 9 2 21 11 0 13 9 4 6 18 4 14 22 26 20 24 18 5 0 27 13 15 4 8 9 27 17 24 13 4 27 3 6 11 24 18 10 5 22 8 7 4 26 22 18 27 1 0 1 21 23 1 10 2 1 21 7 25 24 21 25 23 22 0 14 5 3 6 19 8 7 4 7 27 27 19 26 18 17 3 1 12 8 1 10 18 22 23 25 14 2...

output:

85 0

result:

ok single line: '85 0'

Test #84:

score: 23
Accepted
time: 2ms
memory: 9788kb

input:

100 2
0 1 0 0 1 0 0 1 1 0 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 1 1 1 0 0 0 0 1 1 0 1 0 1 1 0 1 1 1 0 1 0 1 0 0 1 1 1 0 0 0 1 1 0 1 1 1 0 0 1 1 0 1 0 0 0 1 1 0 1 1 0 1 1 1 1 0 0 0 1 1 0 0 0 1 1 0 1 0 0 0 0 1 1 0 1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34...

output:

50 0

result:

ok single line: '50 0'

Test #85:

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

input:

2000 2
0 0 1 1 0 0 0 0 0 0 1 1 1 1 0 1 1 0 1 1 0 0 1 0 1 1 0 0 1 1 0 0 0 1 0 0 1 1 0 0 1 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 1 1 0 1 0 1 1 1 1 0 0 0 0 0 1 0 0 0 1 1 1 0 1 0 0 0 1 1 1 0 1 0 1 1 1 1 0 0 1 1 1 0 0 0 1 1 0 1 1 1 1 0 1 1 1 1 1 0 0 1 1 1 0 1 0 1 1 0 1 0 0 0 0 1 1 0 0 0 0 0 0 1 0...

output:

1001 0

result:

ok single line: '1001 0'

Test #86:

score: 23
Accepted
time: 2ms
memory: 9808kb

input:

100 100
14 93 75 59 44 2 61 56 89 75 70 53 50 78 16 1 48 32 52 21 84 12 75 52 39 89 88 29 71 69 18 0 19 20 66 23 55 99 42 63 46 2 93 23 40 13 64 32 51 47 34 13 95 48 23 55 20 21 87 46 62 7 69 98 66 77 66 16 85 70 2 51 9 9 37 89 85 72 59 13 14 69 4 78 56 84 63 40 35 90 93 44 66 32 25 80 93 99 40 39
0...

output:

4 0

result:

ok single line: '4 0'

Test #87:

score: 23
Accepted
time: 2ms
memory: 8132kb

input:

2000 2000
68 392 1223 140 162 1107 45 1894 1544 255 840 1756 173 1277 1932 1230 1774 932 1637 935 1554 1296 917 158 707 1350 297 1763 1374 1778 637 1079 726 1514 485 678 288 1595 1529 296 414 1803 816 1419 962 1234 521 277 1353 1679 1472 249 1083 1539 442 1925 442 114 116 790 1246 649 15 145 1622 36...

output:

6 0

result:

ok single line: '6 0'

Test #88:

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

input:

99 2
0 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
65
53
0
0
41
0
59
26
87
78
62
23
52
0
97
0
0
90
0
4
77
55
0
73
45
0
19
92
32
0
0
0
82
48
60
54
72...

output:

2 0

result:

ok single line: '2 0'

Test #89:

score: 23
Accepted
time: 2ms
memory: 7852kb

input:

1999 2
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

2 0

result:

ok single line: '2 0'

Test #90:

score: 23
Accepted
time: 1ms
memory: 7688kb

input:

100 2
1 1 1 0 0 1 0 1 1 0 1 0 0 0 1 1 0 1 0 0 1 0 1 0 0 0 1 1 1 1 1 0 1 0 1 1 0 1 1 0 0 1 0 1 0 1 0 0 0 1 0 1 0 0 1 1 0 0 0 1 1 0 1 0 1 1 0 1 1 1 1 0 1 0 0 1 0 0 1 0 0 1 1 0 1 0 1 0 0 0 1 0 0 1 1 1 1 0 1 0
68
34
15
37
60
98
14
80
81
1
94
60
1
45
55
5
29
93
55
41
54
54
96
70
2
32
62
94
15
37
41
90
68...

output:

51 0

result:

ok single line: '51 0'

Test #91:

score: 23
Accepted
time: 2ms
memory: 7948kb

input:

2000 2
1 0 1 0 0 1 0 0 0 0 1 1 1 1 1 1 0 1 0 1 1 0 1 1 0 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 0 0 0 1 1 1 1 1 0 0 1 0 1 1 1 1 1 0 0 1 1 0 1 0 0 1 1 0 1 0 1 0 0 1 1 1 0 0 1 0 1 0 1 1 1 1 0 1 1 0 1 1 1 1 0 1 0 1 1 1 1 1 1 0 0 0 1 1 1 0 1 0 1 1 0 1 0 0 1 1 1 1 0 0 1 0 0 0 0 0 0 0 1 1 1 1 0 1 1 0 0 0 1 1 1 1 0...

output:

1001 0

result:

ok single line: '1001 0'

Test #92:

score: 23
Accepted
time: 2ms
memory: 9772kb

input:

10 2
1 1 1 1 0 1 1 1 1 0
8
8
8
3
9
0
9
0
0

output:

8 0

result:

ok single line: '8 0'

Test #93:

score: 23
Accepted
time: 1ms
memory: 7756kb

input:

100 2
0 0 1 1 1 1 1 0 1 0 0 0 0 0 0 0 1 1 1 0 1 1 1 1 0 0 1 1 1 0 0 1 0 0 1 0 0 0 0 0 0 1 1 1 1 0 0 1 1 0 1 1 1 0 1 1 0 1 1 0 0 0 0 1 0 0 1 0 0 1 1 0 1 1 1 0 0 1 0 1 1 1 1 0 0 1 1 1 0 1 1 1 1 0 1 1 0 1 0 1
27
11
39
3
90
87
91
49
39
95
91
49
89
15
64
27
85
38
43
86
51
28
51
64
54
28
69
87
4
54
27
24
...

output:

46 0

result:

ok single line: '46 0'

Test #94:

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

input:

100 2
1 1 0 1 0 0 1 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 1 1 1 1 0 0 0 0 0 1 1 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 1 0 0 1 1 0 0 0 0 0 0 1
47
84
42
64
90
84
0
84
7
56
35
59
80
98
16
73
56
7
47
33
6
16
24
70
97
3
22
8
19
18
97
7
84
79...

output:

47 12

result:

ok single line: '47 12'

Test #95:

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

input:

2000 2
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 0 1 1 1 0 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1127 147

result:

ok single line: '1127 147'

Test #96:

score: 23
Accepted
time: 1ms
memory: 7748kb

input:

12 8
1 4 0 5 4 1 7 1 2 6 3 1
0
10
9
10
11
7
0
2
0
0
10

output:

4 0

result:

ok single line: '4 0'

Test #97:

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

input:

11 7
2 2 5 0 6 2 5 5 5 5 4
2
10
5
0
7
10
0
7
10
0

output:

3 0

result:

ok single line: '3 0'

Test #98:

score: 23
Accepted
time: 2ms
memory: 7868kb

input:

2000 1214
94 1026 161 676 277 317 994 521 763 1177 1070 228 1083 290 423 642 328 179 713 1180 730 234 70 170 1092 1198 796 819 119 488 743 526 1011 1010 1181 804 994 386 991 1027 739 266 218 1171 697 569 682 891 40 560 377 946 996 653 42 270 43 359 107 771 389 208 419 44 559 870 562 673 451 955 61 1...

output:

7 6

result:

ok single line: '7 6'

Test #99:

score: 23
Accepted
time: 2ms
memory: 7884kb

input:

2000 367
240 338 214 215 327 33 32 206 53 269 186 47 319 131 343 20 146 101 324 327 213 183 148 96 44 2 305 114 170 199 278 4 285 272 108 96 265 284 123 84 285 343 174 52 363 211 62 200 182 192 189 204 22 291 129 131 43 177 36 144 346 356 74 336 258 107 363 259 203 356 32 142 301 284 73 362 257 28 2...

output:

9 6

result:

ok single line: '9 6'

Test #100:

score: 23
Accepted
time: 2ms
memory: 7940kb

input:

2000 1709
1485 645 329 201 238 168 1571 1439 1324 326 889 1583 529 384 621 412 1318 1440 867 1455 944 1383 850 862 376 1565 747 631 1115 1358 676 1599 673 261 1461 1078 205 110 133 938 368 618 1097 771 1085 840 124 873 19 1692 653 1145 1347 225 380 1581 475 758 1190 645 1163 1529 862 423 292 1467 14...

output:

4 3

result:

ok single line: '4 3'

Test #101:

score: 23
Accepted
time: 2ms
memory: 9976kb

input:

1998 669
546 478 393 533 544 272 556 644 418 224 101 256 640 356 503 299 319 13 256 422 107 502 137 364 553 141 383 20 629 111 83 415 107 226 576 634 473 508 429 191 479 270 492 608 534 622 329 10 56 192 603 148 198 125 140 266 449 437 385 169 275 182 306 391 21 231 453 99 518 252 82 371 599 231 129...

output:

2 1

result:

ok single line: '2 1'

Test #102:

score: 23
Accepted
time: 2ms
memory: 10064kb

input:

2000 1290
328 751 977 533 1230 32 440 804 902 68 1058 32 47 25 390 1177 943 977 1010 811 1031 59 942 394 331 57 814 683 547 589 33 1262 862 380 709 1127 430 749 888 749 813 43 844 606 590 980 70 868 708 337 1099 1079 1086 708 684 1279 1129 55 365 433 966 461 1184 263 1165 489 512 183 402 930 886 850...

output:

6 0

result:

ok single line: '6 0'

Test #103:

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

input:

2000 1371
1036 382 1132 1054 337 509 1027 490 1363 135 782 1204 136 976 1132 1299 683 611 1226 235 706 166 7 808 1310 1245 528 148 513 830 1033 883 1170 248 947 857 1000 864 1103 121 717 231 954 1261 1199 341 837 1101 1065 48 392 1117 1014 8 233 840 582 91 1073 405 251 44 1283 193 924 356 379 468 13...

output:

5 4

result:

ok single line: '5 4'

Test #104:

score: 23
Accepted
time: 2ms
memory: 7940kb

input:

2000 1911
1372 1087 544 1695 405 1466 1459 1528 1728 424 99 791 1717 788 1117 1652 627 1393 1432 1562 920 1406 744 61 1516 1758 439 762 1822 1640 1834 507 938 1658 1495 1533 425 510 1392 873 1370 1370 755 696 943 1709 1558 115 695 194 409 808 976 32 306 515 429 408 281 1532 702 1060 627 1289 598 600...

output:

4 2

result:

ok single line: '4 2'

Test #105:

score: 23
Accepted
time: 2ms
memory: 8044kb

input:

2000 2000
226 751 1321 474 474 585 474 895 474 1034 996 474 474 474 474 474 369 137 249 1841 187 1888 474 1094 1982 474 474 474 474 25 1356 474 474 496 1922 1679 474 474 474 1420 474 1106 1890 474 1133 1751 1295 474 474 474 474 474 474 172 1989 474 474 474 474 474 474 474 1608 474 1525 282 367 1953 ...

output:

2 1

result:

ok single line: '2 1'

Test #106:

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

input:

2000 44
10 24 19 22 39 17 35 24 3 12 18 0 37 39 18 32 41 25 28 40 35 25 43 32 30 10 4 3 16 2 32 40 27 34 11 2 36 4 17 20 7 19 37 27 8 7 40 26 27 40 29 31 20 2 9 20 5 7 5 15 42 8 25 40 40 18 41 37 26 8 37 22 33 41 10 19 8 9 40 39 13 18 15 22 12 10 11 35 42 22 24 18 15 23 6 40 5 23 20 4 14 21 40 23 17...

output:

48 0

result:

ok single line: '48 0'

Test #107:

score: 23
Accepted
time: 2ms
memory: 9880kb

input:

2000 202
0 2 3 1 3 2 2 2 3 1 2 2 3 1 1 1 3 1 2 1 3 1 2 3 3 1 1 1 1 1 1 1 1 1 3 3 3 1 3 1 2 1 3 1 1 3 3 3 1 2 1 2 1 2 2 1 2 2 2 2 2 1 2 2 2 2 3 1 2 2 1 1 2 2 3 3 3 3 2 3 1 1 2 3 1 2 1 3 1 1 3 1 1 3 1 3 3 3 3 2 3 3 1 1 3 3 2 1 1 2 2 1 3 2 1 1 1 2 1 3 3 1 2 2 2 3 2 3 1 3 1 3 1 3 3 1 2 3 1 3 2 2 2 2 2 2...

output:

630 233

result:

ok single line: '630 233'

Test #108:

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

input:

1981 199
0 1 1 1 2 1 2 1 1 1 1 1 1 2 1 2 2 2 1 1 1 3 4 3 3 3 3 3 3 3 3 4 3 4 3 3 3 4 4 3 3 6 5 5 6 5 6 6 5 6 5 6 5 6 5 5 6 5 5 5 5 8 8 7 7 8 7 7 8 8 8 7 7 7 7 8 8 7 7 7 7 9 9 10 10 10 10 10 10 9 10 10 9 9 9 10 9 9 9 10 9 11 11 11 12 11 12 11 11 12 11 11 11 12 12 11 11 12 12 11 11 14 14 13 14 14 14 1...

output:

10 1

result:

ok single line: '10 1'

Test #109:

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

input:

2000 1563
2 3 3 0 5 5 4 4 1 4 2 1 1 0 5 4 0 4 0 3 4 5 1 3 1 1 2 3 2 4 4 1 1 2 5 4 1 3 3 3 5 4 0 1 3 0 1 1 5 3 1 4 4 4 0 1 0 1 5 0 2 1 1 2 0 5 1 1 0 5 0 5 5 4 0 5 4 2 0 4 3 3 1 4 1 1 5 5 3 2 4 1 3 1 2 2 2 3 1 4 3 5 1 3 3 4 4 2 1 5 4 1 4 4 4 3 3 1 2 3 1 5 3 3 0 2 5 4 5 4 1 1 1 2 5 5 4 1 3 1 1 0 1 3 5 ...

output:

338 156

result:

ok single line: '338 156'

Test #110:

score: 23
Accepted
time: 3ms
memory: 7836kb

input:

2000 1818
2 4 5 4 4 4 5 3 0 3 4 2 4 0 4 2 1 2 5 4 0 3 5 5 3 5 5 4 5 5 3 1 3 0 4 1 3 1 5 1 0 5 4 3 3 5 5 5 1 4 2 4 0 2 4 2 3 5 5 0 4 1 1 3 3 0 1 5 3 4 2 0 2 0 3 1 4 4 4 1 3 3 4 5 5 5 3 1 2 2 0 3 2 4 2 5 0 5 5 3 2 2 1 4 4 5 5 0 0 2 5 2 4 5 3 4 4 5 0 2 2 4 4 4 0 2 4 5 5 3 3 4 2 5 1 0 3 2 0 2 3 2 3 4 5 ...

output:

340 0

result:

ok single line: '340 0'

Test #111:

score: 23
Accepted
time: 2ms
memory: 7840kb

input:

2000 16
15 6 7 5 0 7 1 6 3 0 14 14 11 4 14 6 2 8 0 7 11 2 6 15 8 7 12 5 2 10 9 14 10 5 8 6 10 2 10 14 2 3 1 9 13 0 10 2 4 9 1 5 0 1 14 15 11 2 1 0 1 8 13 4 2 15 1 11 6 3 7 14 0 8 3 10 6 2 11 8 15 4 1 5 10 7 13 6 6 0 0 1 14 0 9 14 7 15 0 6 14 10 8 0 7 4 11 2 7 1 8 13 1 3 5 3 9 15 11 11 14 7 4 1 0 12 ...

output:

122 0

result:

ok single line: '122 0'

Test #112:

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

input:

2000 1574
2 1 0 0 1 1 0 1 0 0 0 0 1 0 1 0 1 1 1 0 1 0 1 0 1 0 1 1 1 0 1 1 1 1 0 1 1 1 0 0 1 0 0 1 0 0 1 1 0 1 1 0 1 1 0 1 1 0 0 0 0 0 0 0 1 0 1 1 0 1 0 0 1 0 0 1 0 1 0 0 1 0 0 0 1 1 1 0 0 1 0 0 1 1 1 1 0 1 0 0 0 1 1 0 0 1 1 0 0 0 0 0 0 0 1 1 0 0 0 1 0 1 0 1 0 1 1 1 1 0 1 1 1 1 1 1 0 0 1 0 0 1 0 0 0 ...

output:

880 417

result:

ok single line: '880 417'

Test #113:

score: 23
Accepted
time: 1ms
memory: 7756kb

input:

5 3
0 1 2 2 1
0
1
2
3

output:

2 0

result:

ok single line: '2 0'

Test #114:

score: 23
Accepted
time: 2ms
memory: 9740kb

input:

4 2
0 1 0 0
0
0
1

output:

3 0

result:

ok single line: '3 0'

Test #115:

score: 23
Accepted
time: 2ms
memory: 9788kb

input:

9 3
0 0 2 1 2 0 2 1 2
4
8
1
0
4
1
0
7

output:

4 2

result:

ok single line: '4 2'

Test #116:

score: 23
Accepted
time: 1ms
memory: 9792kb

input:

8 3
0 2 1 2 2 1 1 1
6
3
0
6
3
0
3

output:

3 2

result:

ok single line: '3 2'

Subtask #5:

score: 19
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #117:

score: 19
Accepted
time: 1ms
memory: 9740kb

input:

1 1
0

output:

1 0

result:

ok single line: '1 0'

Test #118:

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

input:

5 2
0 1 0 0 0
0
1
2
3

output:

4 0

result:

ok single line: '4 0'

Test #119:

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

input:

10 9
6 5 6 2 5 4 5 3 4 1
0
1
2
3
4
5
6
7
8

output:

3 0

result:

ok single line: '3 0'

Test #120:

score: 19
Accepted
time: 1ms
memory: 7768kb

input:

15 8
3 6 7 6 7 6 6 0 6 7 3 6 2 3 3
0
1
2
3
4
5
6
7
8
9
10
11
12
13

output:

6 0

result:

ok single line: '6 0'

Test #121:

score: 19
Accepted
time: 1ms
memory: 7688kb

input:

7 3
1 1 1 2 1 0 1
0
1
2
3
4
5

output:

5 0

result:

ok single line: '5 0'

Test #122:

score: 19
Accepted
time: 1ms
memory: 7748kb

input:

8 6
1 4 0 1 3 0 4 5
0
1
2
3
4
5
6

output:

2 0

result:

ok single line: '2 0'

Test #123:

score: 19
Accepted
time: 2ms
memory: 9820kb

input:

100 97
73 42 17 20 20 71 6 52 18 93 34 27 96 35 77 27 46 62 23 83 12 13 91 61 82 0 59 82 6 67 24 37 4 61 2 6 31 12 21 37 47 39 44 85 92 16 66 39 48 69 57 62 75 7 87 68 89 44 77 69 12 6 19 31 30 2 14 90 30 37 67 5 88 53 59 3 1 45 75 82 59 27 51 0 85 65 57 75 74 53 35 44 87 86 77 52 35 23 87 87
0
1
2
...

output:

4 0

result:

ok single line: '4 0'

Test #124:

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

input:

2000 28
13 0 11 21 0 3 7 0 2 10 25 17 13 21 19 12 9 17 21 12 12 17 9 2 21 11 0 13 9 4 6 18 4 14 22 26 20 24 18 5 0 27 13 15 4 8 9 27 17 24 13 4 27 3 6 11 24 18 10 5 22 8 7 4 26 22 18 27 1 0 1 21 23 1 10 2 1 21 7 25 24 21 25 23 22 0 14 5 3 6 19 8 7 4 7 27 27 19 26 18 17 3 1 12 8 1 10 18 22 23 25 14 2...

output:

85 0

result:

ok single line: '85 0'

Test #125:

score: 19
Accepted
time: 22ms
memory: 25484kb

input:

100000 59066
10203 30163 14221 32641 57632 52742 51576 33938 17167 56268 10461 37834 58393 19522 10361 4859 50498 54209 40282 44610 7141 54240 58622 15568 57813 20977 23646 51685 16859 23152 37761 20080 6279 48735 39054 5181 35803 38656 7011 54044 4665 29269 39955 44267 6927 1328 56776 24684 2653 10...

output:

10 0

result:

ok single line: '10 0'

Test #126:

score: 19
Accepted
time: 2ms
memory: 9876kb

input:

100 2
0 1 0 0 1 0 0 1 1 0 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 1 1 1 0 0 0 0 1 1 0 1 0 1 1 0 1 1 1 0 1 0 1 0 0 1 1 1 0 0 0 1 1 0 1 1 1 0 0 1 1 0 1 0 0 0 1 1 0 1 1 0 1 1 1 1 0 0 0 1 1 0 0 0 1 1 0 1 0 0 0 0 1 1 0 1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34...

output:

50 0

result:

ok single line: '50 0'

Test #127:

score: 19
Accepted
time: 2ms
memory: 8020kb

input:

2000 2
0 0 1 1 0 0 0 0 0 0 1 1 1 1 0 1 1 0 1 1 0 0 1 0 1 1 0 0 1 1 0 0 0 1 0 0 1 1 0 0 1 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 1 1 0 1 0 1 1 1 1 0 0 0 0 0 1 0 0 0 1 1 1 0 1 0 0 0 1 1 1 0 1 0 1 1 1 1 0 0 1 1 1 0 0 0 1 1 0 1 1 1 1 0 1 1 1 1 1 0 0 1 1 1 0 1 0 1 1 0 1 0 0 0 0 1 1 0 0 0 0 0 0 1 0...

output:

1001 0

result:

ok single line: '1001 0'

Test #128:

score: 19
Accepted
time: 28ms
memory: 23196kb

input:

100000 2
0 0 1 0 0 0 1 0 0 0 0 1 1 1 1 0 0 0 0 0 1 0 1 0 1 0 1 1 0 1 0 1 1 0 1 1 1 0 0 1 0 0 1 1 0 0 1 1 0 1 1 0 1 0 1 1 0 1 1 1 1 0 0 1 1 1 1 1 1 1 0 1 0 0 1 0 0 1 1 1 1 1 1 0 0 1 0 1 1 0 1 1 0 0 1 0 0 0 0 0 1 1 0 1 0 0 0 1 1 0 0 1 1 0 1 1 1 0 1 1 1 1 0 0 1 1 1 0 1 1 0 1 1 1 1 1 0 1 1 0 0 1 0 1 0 0...

output:

50198 0

result:

ok single line: '50198 0'

Test #129:

score: 19
Accepted
time: 1ms
memory: 7780kb

input:

100 100
14 93 75 59 44 2 61 56 89 75 70 53 50 78 16 1 48 32 52 21 84 12 75 52 39 89 88 29 71 69 18 0 19 20 66 23 55 99 42 63 46 2 93 23 40 13 64 32 51 47 34 13 95 48 23 55 20 21 87 46 62 7 69 98 66 77 66 16 85 70 2 51 9 9 37 89 85 72 59 13 14 69 4 78 56 84 63 40 35 90 93 44 66 32 25 80 93 99 40 39
0...

output:

4 0

result:

ok single line: '4 0'

Test #130:

score: 19
Accepted
time: 2ms
memory: 8068kb

input:

2000 2000
68 392 1223 140 162 1107 45 1894 1544 255 840 1756 173 1277 1932 1230 1774 932 1637 935 1554 1296 917 158 707 1350 297 1763 1374 1778 637 1079 726 1514 485 678 288 1595 1529 296 414 1803 816 1419 962 1234 521 277 1353 1679 1472 249 1083 1539 442 1925 442 114 116 790 1246 649 15 145 1622 36...

output:

6 0

result:

ok single line: '6 0'

Test #131:

score: 19
Accepted
time: 30ms
memory: 27100kb

input:

100000 100000
41728 93320 38571 44676 59528 37978 81336 71690 19433 62851 10920 32382 57235 11051 54769 96948 26321 8339 26066 61016 79074 40324 13106 94743 16700 60377 60008 60349 77853 65660 4887 16582 91933 4573 43258 30974 68341 21985 25073 6706 28676 32064 29269 78970 28685 53456 23597 67768 65...

output:

8 0

result:

ok single line: '8 0'

Test #132:

score: 19
Accepted
time: 1ms
memory: 7748kb

input:

99 2
0 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
65
53
0
0
41
0
59
26
87
78
62
23
52
0
97
0
0
90
0
4
77
55
0
73
45
0
19
92
32
0
0
0
82
48
60
54
72...

output:

2 0

result:

ok single line: '2 0'

Test #133:

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

input:

1999 2
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

2 0

result:

ok single line: '2 0'

Test #134:

score: 19
Accepted
time: 30ms
memory: 14048kb

input:

99999 2
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

2 0

result:

ok single line: '2 0'

Test #135:

score: 19
Accepted
time: 2ms
memory: 9744kb

input:

100 2
1 1 1 0 0 1 0 1 1 0 1 0 0 0 1 1 0 1 0 0 1 0 1 0 0 0 1 1 1 1 1 0 1 0 1 1 0 1 1 0 0 1 0 1 0 1 0 0 0 1 0 1 0 0 1 1 0 0 0 1 1 0 1 0 1 1 0 1 1 1 1 0 1 0 0 1 0 0 1 0 0 1 1 0 1 0 1 0 0 0 1 0 0 1 1 1 1 0 1 0
68
34
15
37
60
98
14
80
81
1
94
60
1
45
55
5
29
93
55
41
54
54
96
70
2
32
62
94
15
37
41
90
68...

output:

51 0

result:

ok single line: '51 0'

Test #136:

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

input:

2000 2
1 0 1 0 0 1 0 0 0 0 1 1 1 1 1 1 0 1 0 1 1 0 1 1 0 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 0 0 0 1 1 1 1 1 0 0 1 0 1 1 1 1 1 0 0 1 1 0 1 0 0 1 1 0 1 0 1 0 0 1 1 1 0 0 1 0 1 0 1 1 1 1 0 1 1 0 1 1 1 1 0 1 0 1 1 1 1 1 1 0 0 0 1 1 1 0 1 0 1 1 0 1 0 0 1 1 1 1 0 0 1 0 0 0 0 0 0 0 1 1 1 1 0 1 1 0 0 0 1 1 1 1 0...

output:

1001 0

result:

ok single line: '1001 0'

Test #137:

score: 19
Accepted
time: 55ms
memory: 17600kb

input:

100000 2
0 0 1 1 1 0 1 1 1 1 0 1 0 0 0 0 0 1 0 1 0 1 0 1 0 0 1 0 1 1 1 0 0 1 1 0 0 0 0 0 1 0 0 1 0 1 0 1 0 1 0 0 0 0 1 1 1 1 0 1 0 1 1 1 0 0 0 1 0 0 1 1 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 1 0 1 1 0 0 1 0 1 0 0 1 1 1 0 0 0 1 0 0 1 0 1 0 0 0 1 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 1 0 1 1 1 1 1 0 0 0 0 0 0 0...

output:

50001 0

result:

ok single line: '50001 0'

Test #138:

score: 19
Accepted
time: 14ms
memory: 10256kb

input:

100000 2
0 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:

7 2

result:

ok single line: '7 2'

Test #139:

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

input:

10 2
1 1 1 1 0 1 1 1 1 0
8
8
8
3
9
0
9
0
0

output:

8 0

result:

ok single line: '8 0'

Test #140:

score: 19
Accepted
time: 1ms
memory: 7768kb

input:

100 2
0 0 1 1 1 1 1 0 1 0 0 0 0 0 0 0 1 1 1 0 1 1 1 1 0 0 1 1 1 0 0 1 0 0 1 0 0 0 0 0 0 1 1 1 1 0 0 1 1 0 1 1 1 0 1 1 0 1 1 0 0 0 0 1 0 0 1 0 0 1 1 0 1 1 1 0 0 1 0 1 1 1 1 0 0 1 1 1 0 1 1 1 1 0 1 1 0 1 0 1
27
11
39
3
90
87
91
49
39
95
91
49
89
15
64
27
85
38
43
86
51
28
51
64
54
28
69
87
4
54
27
24
...

output:

46 0

result:

ok single line: '46 0'

Test #141:

score: 19
Accepted
time: 43ms
memory: 14000kb

input:

100000 2
1 0 0 0 0 1 1 1 1 0 0 1 0 0 1 0 1 1 0 1 1 1 1 0 0 0 0 0 1 0 0 0 1 0 1 1 0 1 0 1 0 1 0 0 0 0 1 1 0 0 0 0 1 0 0 1 1 1 1 0 1 1 1 1 0 1 0 1 1 0 0 1 0 0 0 0 0 1 1 1 0 0 0 1 1 1 0 0 1 1 0 1 1 1 1 1 0 1 1 0 1 0 0 1 0 1 1 1 1 0 1 0 1 1 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 0 1 0 0 0 0 0...

output:

50040 0

result:

ok single line: '50040 0'

Test #142:

score: 19
Accepted
time: 45ms
memory: 13868kb

input:

100000 2
1 0 0 1 0 0 1 0 1 1 1 0 1 1 0 0 1 1 0 1 1 1 0 0 0 1 1 0 0 0 1 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 1 0 0 0 1 0 0 1 1 0 0 1 0 0 1 1 1 0 0 1 0 0 1 0 1 1 0 0 0 0 1 0 1 0 1 1 1 1 1 0 1 0 1 1 1 1 0 0 1 0 1 1 1 1 0 0 1 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 1 0 0 0 1 1 0 0 1 0 0 0 1 1 0...

output:

50006 0

result:

ok single line: '50006 0'

Test #143:

score: 19
Accepted
time: 2ms
memory: 7768kb

input:

100 2
1 1 0 1 0 0 1 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 1 1 1 1 0 0 0 0 0 1 1 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 1 0 0 1 1 0 0 0 0 0 0 1
47
84
42
64
90
84
0
84
7
56
35
59
80
98
16
73
56
7
47
33
6
16
24
70
97
3
22
8
19
18
97
7
84
79...

output:

47 12

result:

ok single line: '47 12'

Test #144:

score: 19
Accepted
time: 2ms
memory: 7896kb

input:

2000 2
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 0 1 1 1 0 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1127 147

result:

ok single line: '1127 147'

Test #145:

score: 19
Accepted
time: 41ms
memory: 13932kb

input:

100000 2
1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

39105 5115

result:

ok single line: '39105 5115'

Test #146:

score: 19
Accepted
time: 46ms
memory: 14080kb

input:

100000 2
0 0 0 1 0 1 1 1 1 0 0 1 1 1 0 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 0 0 1 0 1 1 0 1 1 1 1 1 1 0 1 1 0 1 0 1 1 1 1 1 1...

output:

61321 12576

result:

ok single line: '61321 12576'

Test #147:

score: 19
Accepted
time: 44ms
memory: 13680kb

input:

100000 2
0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 1 0 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1...

output:

75885 8789

result:

ok single line: '75885 8789'

Test #148:

score: 19
Accepted
time: 2ms
memory: 9788kb

input:

12 8
1 4 0 5 4 1 7 1 2 6 3 1
0
10
9
10
11
7
0
2
0
0
10

output:

4 0

result:

ok single line: '4 0'

Test #149:

score: 19
Accepted
time: 1ms
memory: 7820kb

input:

11 7
2 2 5 0 6 2 5 5 5 5 4
2
10
5
0
7
10
0
7
10
0

output:

3 0

result:

ok single line: '3 0'

Test #150:

score: 19
Accepted
time: 2ms
memory: 9868kb

input:

2000 1214
94 1026 161 676 277 317 994 521 763 1177 1070 228 1083 290 423 642 328 179 713 1180 730 234 70 170 1092 1198 796 819 119 488 743 526 1011 1010 1181 804 994 386 991 1027 739 266 218 1171 697 569 682 891 40 560 377 946 996 653 42 270 43 359 107 771 389 208 419 44 559 870 562 673 451 955 61 1...

output:

7 6

result:

ok single line: '7 6'

Test #151:

score: 19
Accepted
time: 3ms
memory: 9920kb

input:

2000 367
240 338 214 215 327 33 32 206 53 269 186 47 319 131 343 20 146 101 324 327 213 183 148 96 44 2 305 114 170 199 278 4 285 272 108 96 265 284 123 84 285 343 174 52 363 211 62 200 182 192 189 204 22 291 129 131 43 177 36 144 346 356 74 336 258 107 363 259 203 356 32 142 301 284 73 362 257 28 2...

output:

9 6

result:

ok single line: '9 6'

Test #152:

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

input:

2000 1709
1485 645 329 201 238 168 1571 1439 1324 326 889 1583 529 384 621 412 1318 1440 867 1455 944 1383 850 862 376 1565 747 631 1115 1358 676 1599 673 261 1461 1078 205 110 133 938 368 618 1097 771 1085 840 124 873 19 1692 653 1145 1347 225 380 1581 475 758 1190 645 1163 1529 862 423 292 1467 14...

output:

4 3

result:

ok single line: '4 3'

Test #153:

score: 19
Accepted
time: 36ms
memory: 16984kb

input:

100000 75391
6003 72241 28741 19704 62287 24690 41725 29510 57883 38477 33470 4992 35443 46446 51948 19117 63206 70119 59682 17977 17585 63767 27706 24382 5246 12260 21715 30157 71722 52898 17011 8901 11539 24958 24021 62637 49016 39312 43249 47312 34246 42988 54094 15067 35673 17443 54173 74045 177...

output:

5 4

result:

ok single line: '5 4'

Test #154:

score: 19
Accepted
time: 50ms
memory: 16548kb

input:

100000 49117
41499 634 5420 22557 37968 3746 45332 11341 478 17636 21492 12335 24063 6190 18849 15466 21965 4971 16528 23666 26722 12564 1621 44222 22252 1328 7231 47550 38290 41788 33437 31121 20010 18004 7984 36028 6592 19326 39515 8315 9147 23356 9582 7518 22805 24271 17382 1169 7811 24026 15104 ...

output:

6 3

result:

ok single line: '6 3'

Test #155:

score: 19
Accepted
time: 48ms
memory: 16576kb

input:

100000 12500
3351 6242 3439 6257 5667 2932 5195 5012 5862 59 6395 10258 11579 6284 8052 1326 2424 367 4808 11951 2511 3009 11535 363 1598 3821 5241 4749 4520 11867 9406 5969 10785 7052 12323 546 12447 4428 2601 4526 7179 5328 510 6179 1390 11793 10075 7987 11764 7577 11329 8480 303 3771 5525 10954 4...

output:

10 0

result:

ok single line: '10 0'

Test #156:

score: 19
Accepted
time: 40ms
memory: 13300kb

input:

100000 12500
1863 9353 1760 3692 12493 5739 7507 4213 8749 7520 1300 6286 11171 8248 12484 5693 2553 10863 683 6071 6332 8639 4169 6304 9237 10023 4036 2507 9564 1555 713 1308 1205 5730 3200 10588 8826 7249 10197 10061 8312 1477 222 8425 753 9367 5506 5340 6606 4781 12235 2460 6006 8719 5709 12076 2...

output:

10 8

result:

ok single line: '10 8'

Test #157:

score: 19
Accepted
time: 36ms
memory: 16672kb

input:

100000 96893
95051 72243 10063 60661 91889 47907 52292 43931 95258 20748 35404 2410 62255 24866 81818 47996 58452 41934 57010 14996 45631 14835 45612 82642 35070 16256 822 8752 18362 68818 59643 82399 90061 80210 30083 38874 59046 3585 10982 29084 82862 44312 66064 42244 15172 13194 59371 10555 7510...

output:

5 4

result:

ok single line: '5 4'

Test #158:

score: 19
Accepted
time: 46ms
memory: 21112kb

input:

100000 50001
0 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99...

output:

2 0

result:

ok single line: '2 0'

Test #159:

score: 19
Accepted
time: 41ms
memory: 18624kb

input:

99999 33336
15028 24699 11531 16033 15308 19476 1876 26665 10206 23562 2457 16515 27494 8224 20364 5708 23502 28651 18632 2605 30444 27706 24511 2402 29194 4277 11533 29989 10623 9573 29600 28753 30975 5802 22730 14558 18279 27181 22000 9237 15382 20303 31855 25528 15993 19556 4529 3241 14917 26152 ...

output:

2 1

result:

ok single line: '2 1'

Test #160:

score: 19
Accepted
time: 2ms
memory: 7964kb

input:

1998 669
546 478 393 533 544 272 556 644 418 224 101 256 640 356 503 299 319 13 256 422 107 502 137 364 553 141 383 20 629 111 83 415 107 226 576 634 473 508 429 191 479 270 492 608 534 622 329 10 56 192 603 148 198 125 140 266 449 437 385 169 275 182 306 391 21 231 453 99 518 252 82 371 599 231 129...

output:

2 1

result:

ok single line: '2 1'

Test #161:

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

input:

2000 1290
328 751 977 533 1230 32 440 804 902 68 1058 32 47 25 390 1177 943 977 1010 811 1031 59 942 394 331 57 814 683 547 589 33 1262 862 380 709 1127 430 749 888 749 813 43 844 606 590 980 70 868 708 337 1099 1079 1086 708 684 1279 1129 55 365 433 966 461 1184 263 1165 489 512 183 402 930 886 850...

output:

6 0

result:

ok single line: '6 0'

Test #162:

score: 19
Accepted
time: 2ms
memory: 7872kb

input:

2000 1371
1036 382 1132 1054 337 509 1027 490 1363 135 782 1204 136 976 1132 1299 683 611 1226 235 706 166 7 808 1310 1245 528 148 513 830 1033 883 1170 248 947 857 1000 864 1103 121 717 231 954 1261 1199 341 837 1101 1065 48 392 1117 1014 8 233 840 582 91 1073 405 251 44 1283 193 924 356 379 468 13...

output:

5 4

result:

ok single line: '5 4'

Test #163:

score: 19
Accepted
time: 2ms
memory: 7940kb

input:

2000 1911
1372 1087 544 1695 405 1466 1459 1528 1728 424 99 791 1717 788 1117 1652 627 1393 1432 1562 920 1406 744 61 1516 1758 439 762 1822 1640 1834 507 938 1658 1495 1533 425 510 1392 873 1370 1370 755 696 943 1709 1558 115 695 194 409 808 976 32 306 515 429 408 281 1532 702 1060 627 1289 598 600...

output:

4 2

result:

ok single line: '4 2'

Test #164:

score: 19
Accepted
time: 5ms
memory: 10648kb

input:

10000 9323
962 8383 6995 1036 4327 3860 3350 9071 1244 3604 2401 6242 5424 2967 2800 5578 1656 2138 5652 7348 5985 8430 2556 2437 6201 4804 5924 697 1270 877 5874 3419 4160 103 1008 6025 2894 3635 8788 8469 6474 7559 2906 4014 4519 6787 8724 4359 6203 2060 5922 3876 3026 6031 875 2248 6742 7236 4338...

output:

5 2

result:

ok single line: '5 2'

Test #165:

score: 19
Accepted
time: 33ms
memory: 15572kb

input:

100000 52420
26262 46221 25641 24296 987 11464 17938 10592 41066 9659 15503 38267 40116 21923 13900 5632 26410 32886 25879 50594 13791 50209 3481 3932 12821 29655 30937 15889 9008 5486 16266 51350 51993 11855 33156 35354 17563 38460 27422 41883 32313 17975 15432 41121 6075 1750 642 37390 6962 6646 4...

output:

8 7

result:

ok single line: '8 7'

Test #166:

score: 19
Accepted
time: 49ms
memory: 17456kb

input:

100000 90378
67239 25212 89662 59573 7454 57178 59461 26816 14645 63568 24161 7227 86746 38584 27486 40208 89126 4327 29837 8653 62071 42190 20598 35271 87322 37795 18292 34373 87872 886 50277 5101 75648 59283 88536 32969 10734 4199 3813 74956 73859 78583 64283 61149 53760 14608 45928 81377 51331 16...

output:

7 3

result:

ok single line: '7 3'

Test #167:

score: 19
Accepted
time: 59ms
memory: 19808kb

input:

100000 97326
3834 63201 65063 61863 28834 19701 96074 84029 35961 83262 87561 49943 38607 59670 63612 50459 74106 85100 44599 43239 62860 862 83576 89134 17431 95440 35750 21704 70568 76336 10132 36366 72266 23271 6664 7859 79197 10223 84254 67287 90473 49469 54174 52372 59500 89297 92122 43764 3476...

output:

9 0

result:

ok single line: '9 0'

Test #168:

score: 19
Accepted
time: 38ms
memory: 16500kb

input:

100000 78050
31469 58640 36595 28575 59252 3155 8187 60461 49864 39581 49504 57438 3706 51926 21777 77093 59307 20236 67491 3332 56597 25394 34811 71580 67844 25966 22307 3244 57386 59877 2267 58834 8993 37893 72864 18036 9520 44587 39438 50974 33153 5724 3842 12762 38045 67979 55814 32838 53535 190...

output:

6 5

result:

ok single line: '6 5'

Test #169:

score: 19
Accepted
time: 2ms
memory: 10024kb

input:

2000 2000
226 751 1321 474 474 585 474 895 474 1034 996 474 474 474 474 474 369 137 249 1841 187 1888 474 1094 1982 474 474 474 474 25 1356 474 474 496 1922 1679 474 474 474 1420 474 1106 1890 474 1133 1751 1295 474 474 474 474 474 474 172 1989 474 474 474 474 474 474 474 1608 474 1525 282 367 1953 ...

output:

2 1

result:

ok single line: '2 1'

Test #170:

score: 19
Accepted
time: 2ms
memory: 9968kb

input:

2000 44
10 24 19 22 39 17 35 24 3 12 18 0 37 39 18 32 41 25 28 40 35 25 43 32 30 10 4 3 16 2 32 40 27 34 11 2 36 4 17 20 7 19 37 27 8 7 40 26 27 40 29 31 20 2 9 20 5 7 5 15 42 8 25 40 40 18 41 37 26 8 37 22 33 41 10 19 8 9 40 39 13 18 15 22 12 10 11 35 42 22 24 18 15 23 6 40 5 23 20 4 14 21 40 23 17...

output:

48 0

result:

ok single line: '48 0'

Test #171:

score: 19
Accepted
time: 2ms
memory: 9928kb

input:

2000 202
0 2 3 1 3 2 2 2 3 1 2 2 3 1 1 1 3 1 2 1 3 1 2 3 3 1 1 1 1 1 1 1 1 1 3 3 3 1 3 1 2 1 3 1 1 3 3 3 1 2 1 2 1 2 2 1 2 2 2 2 2 1 2 2 2 2 3 1 2 2 1 1 2 2 3 3 3 3 2 3 1 1 2 3 1 2 1 3 1 1 3 1 1 3 1 3 3 3 3 2 3 3 1 1 3 3 2 1 1 2 2 1 3 2 1 1 1 2 1 3 3 1 2 2 2 3 2 3 1 3 1 3 1 3 3 1 2 3 1 3 2 2 2 2 2 2...

output:

630 233

result:

ok single line: '630 233'

Test #172:

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

input:

1981 199
0 1 1 1 2 1 2 1 1 1 1 1 1 2 1 2 2 2 1 1 1 3 4 3 3 3 3 3 3 3 3 4 3 4 3 3 3 4 4 3 3 6 5 5 6 5 6 6 5 6 5 6 5 6 5 5 6 5 5 5 5 8 8 7 7 8 7 7 8 8 8 7 7 7 7 8 8 7 7 7 7 9 9 10 10 10 10 10 10 9 10 10 9 9 9 10 9 9 9 10 9 11 11 11 12 11 12 11 11 12 11 11 11 12 12 11 11 12 12 11 11 14 14 13 14 14 14 1...

output:

10 1

result:

ok single line: '10 1'

Test #173:

score: 19
Accepted
time: 3ms
memory: 7824kb

input:

2000 1563
2 3 3 0 5 5 4 4 1 4 2 1 1 0 5 4 0 4 0 3 4 5 1 3 1 1 2 3 2 4 4 1 1 2 5 4 1 3 3 3 5 4 0 1 3 0 1 1 5 3 1 4 4 4 0 1 0 1 5 0 2 1 1 2 0 5 1 1 0 5 0 5 5 4 0 5 4 2 0 4 3 3 1 4 1 1 5 5 3 2 4 1 3 1 2 2 2 3 1 4 3 5 1 3 3 4 4 2 1 5 4 1 4 4 4 3 3 1 2 3 1 5 3 3 0 2 5 4 5 4 1 1 1 2 5 5 4 1 3 1 1 0 1 3 5 ...

output:

338 156

result:

ok single line: '338 156'

Test #174:

score: 19
Accepted
time: 3ms
memory: 7912kb

input:

2000 1818
2 4 5 4 4 4 5 3 0 3 4 2 4 0 4 2 1 2 5 4 0 3 5 5 3 5 5 4 5 5 3 1 3 0 4 1 3 1 5 1 0 5 4 3 3 5 5 5 1 4 2 4 0 2 4 2 3 5 5 0 4 1 1 3 3 0 1 5 3 4 2 0 2 0 3 1 4 4 4 1 3 3 4 5 5 5 3 1 2 2 0 3 2 4 2 5 0 5 5 3 2 2 1 4 4 5 5 0 0 2 5 2 4 5 3 4 4 5 0 2 2 4 4 4 0 2 4 5 5 3 3 4 2 5 1 0 3 2 0 2 3 2 3 4 5 ...

output:

340 0

result:

ok single line: '340 0'

Test #175:

score: 19
Accepted
time: 2ms
memory: 7880kb

input:

2000 16
15 6 7 5 0 7 1 6 3 0 14 14 11 4 14 6 2 8 0 7 11 2 6 15 8 7 12 5 2 10 9 14 10 5 8 6 10 2 10 14 2 3 1 9 13 0 10 2 4 9 1 5 0 1 14 15 11 2 1 0 1 8 13 4 2 15 1 11 6 3 7 14 0 8 3 10 6 2 11 8 15 4 1 5 10 7 13 6 6 0 0 1 14 0 9 14 7 15 0 6 14 10 8 0 7 4 11 2 7 1 8 13 1 3 5 3 9 15 11 11 14 7 4 1 0 12 ...

output:

122 0

result:

ok single line: '122 0'

Test #176:

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

input:

2000 1574
2 1 0 0 1 1 0 1 0 0 0 0 1 0 1 0 1 1 1 0 1 0 1 0 1 0 1 1 1 0 1 1 1 1 0 1 1 1 0 0 1 0 0 1 0 0 1 1 0 1 1 0 1 1 0 1 1 0 0 0 0 0 0 0 1 0 1 1 0 1 0 0 1 0 0 1 0 1 0 0 1 0 0 0 1 1 1 0 0 1 0 0 1 1 1 1 0 1 0 0 0 1 1 0 0 1 1 0 0 0 0 0 0 0 1 1 0 0 0 1 0 1 0 1 0 1 1 1 1 0 1 1 1 1 1 1 0 0 1 0 0 1 0 0 0 ...

output:

880 417

result:

ok single line: '880 417'

Test #177:

score: 19
Accepted
time: 55ms
memory: 22192kb

input:

100000 100000
29872 4422 25961 49791 4422 4422 64237 4422 4422 53115 4422 16114 4422 18147 16432 4422 71227 4942 4422 4422 14364 96986 95008 4422 4422 41124 4422 87996 53097 16696 18958 4422 4422 48335 4422 4422 39805 16433 4422 4422 49668 4422 4422 49985 4422 4422 4422 13057 45772 4422 50979 46611 ...

output:

2 1

result:

ok single line: '2 1'

Test #178:

score: 19
Accepted
time: 105ms
memory: 14788kb

input:

100000 316
224 176 257 99 98 147 256 88 121 248 57 173 173 28 69 116 159 33 107 145 143 304 182 189 80 168 196 175 169 213 60 139 57 195 41 233 11 69 307 63 123 178 211 99 71 24 147 87 14 272 97 54 4 256 314 173 212 37 3 243 61 126 72 45 207 197 164 78 76 217 144 286 72 64 128 145 81 169 237 110 233...

output:

317 0

result:

ok single line: '317 0'

Test #179:

score: 19
Accepted
time: 40ms
memory: 14384kb

input:

100000 43742
22828 31060 9191 10626 16348 34756 25083 29753 34778 38555 32648 8782 27870 34543 23297 24711 11970 30335 31882 17693 31330 33028 28918 27214 2160 4517 34797 19341 10502 1598 27684 34659 3189 26723 34571 1418 12742 38151 27345 28254 12950 19339 3616 2365 10821 15505 41717 25043 10306 40...

output:

7 6

result:

ok single line: '7 6'

Test #180:

score: 19
Accepted
time: 4ms
memory: 10324kb

input:

10000 5047
2 1 1 0 1 1 0 1 0 1 1 1 1 0 0 1 0 1 0 0 0 0 0 0 1 1 1 1 1 1 0 1 1 1 1 1 0 0 0 1 0 1 0 0 1 0 0 0 1 1 0 0 0 1 1 0 0 0 0 1 0 0 0 1 1 0 0 1 0 1 0 1 0 1 1 0 1 1 1 1 1 0 0 1 0 0 0 1 1 0 0 1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 0 1 1 0 1 0 0 0 0 1 1 0 1 0 1 0 0 1 1 1 1 0 1 1 1 0 1 0 1 1 1 1...

output:

4063 1989

result:

ok single line: '4063 1989'

Test #181:

score: 19
Accepted
time: 43ms
memory: 13808kb

input:

100000 69192
2 1 1 0 0 0 1 0 1 0 1 0 0 0 1 0 0 0 1 0 1 1 1 0 1 1 0 0 0 1 0 0 1 1 0 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 0 0 0 0 1 0 0 0 1 1 1 1 0 1 1 0 0 1 0 0 0 1 0 0 1 1 1 0 1 1 0 0 1 0 1 1 1 0 0 1 1 0 0 0 1 1 1 1 0 1 0 0 1 1 1 0 1 1 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 1 1 0 0 1 0 0 1 0 0 1 0 1 1 1 1 0...

output:

48601 21526

result:

ok single line: '48601 21526'

Test #182:

score: 19
Accepted
time: 2ms
memory: 8412kb

input:

10000 2611
2 4 1 3 1 4 1 5 1 5 3 3 1 2 1 5 4 1 0 2 1 5 4 1 0 5 2 0 0 0 2 2 5 4 3 4 5 3 5 3 5 0 3 1 2 3 5 3 2 5 5 4 2 5 1 2 0 4 0 0 0 0 3 3 1 2 2 0 3 3 1 5 5 2 3 1 0 2 3 2 5 5 3 5 2 5 5 1 0 4 5 1 5 5 5 2 0 4 4 4 5 1 1 2 0 0 5 3 5 2 0 1 1 2 4 5 2 5 5 4 1 0 2 0 0 1 1 1 2 3 4 4 2 4 3 0 5 3 4 4 3 4 5 1 1...

output:

1722 1038

result:

ok single line: '1722 1038'

Test #183:

score: 19
Accepted
time: 3ms
memory: 10000kb

input:

10000 3619
2 0 4 3 3 3 4 5 2 0 1 4 5 1 3 2 2 1 2 3 5 5 2 4 1 5 5 1 0 3 1 0 5 1 2 4 5 3 3 3 1 2 4 0 0 3 4 2 5 0 4 5 4 2 2 5 0 5 0 0 2 0 3 5 5 5 3 5 2 3 2 2 2 1 4 4 2 1 5 3 1 1 0 4 4 2 5 5 2 2 2 2 0 2 1 2 1 1 5 5 3 3 2 2 5 5 3 2 2 2 2 0 3 2 0 2 4 3 5 2 0 4 0 1 3 1 0 3 0 5 3 0 0 4 4 4 1 2 4 3 2 1 2 4 1...

output:

1663 0

result:

ok single line: '1663 0'

Test #184:

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

input:

10000 7480
2 2 3 1 4 5 0 5 4 4 2 1 1 1 0 0 2 1 1 2 1 0 3 0 0 0 3 1 0 0 3 4 4 4 3 3 3 3 2 4 0 2 5 1 4 5 0 0 2 5 4 2 1 1 0 0 3 0 5 4 1 2 0 1 2 0 3 5 0 5 1 2 4 2 5 2 3 4 3 4 4 1 0 0 1 3 0 2 5 4 0 0 3 1 0 2 3 4 1 4 1 4 0 5 4 5 2 0 1 1 3 2 1 4 0 5 3 5 5 5 3 4 3 3 3 0 0 4 0 5 2 1 5 3 2 2 2 5 2 0 0 0 2 0 4...

output:

1749 0

result:

ok single line: '1749 0'

Test #185:

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

input:

10000 840
2 2 5 2 3 3 0 1 1 2 2 5 2 4 4 3 1 0 1 5 3 5 1 3 0 3 0 3 2 3 1 0 0 4 3 1 0 0 1 2 0 4 2 4 3 4 4 2 1 1 2 1 2 2 5 5 3 0 1 2 2 2 4 1 3 5 5 1 5 4 5 3 1 1 5 1 3 2 4 3 3 1 4 0 3 0 2 3 0 3 2 3 2 3 2 1 3 0 0 2 1 3 2 3 2 3 1 2 5 1 0 0 4 1 0 4 1 0 0 2 2 2 1 3 1 0 1 2 0 0 1 4 3 5 0 1 2 2 4 1 2 3 1 2 2 ...

output:

1724 0

result:

ok single line: '1724 0'

Test #186:

score: 19
Accepted
time: 39ms
memory: 13816kb

input:

100000 85815
2 4 1 5 5 2 5 3 2 5 4 0 2 3 4 4 5 1 3 0 0 4 5 1 1 4 5 0 1 2 1 2 2 0 5 2 0 4 5 0 2 4 0 4 0 3 3 2 4 5 4 5 2 4 4 1 2 4 4 3 4 3 4 4 4 1 2 0 1 5 1 3 1 2 4 0 2 0 4 2 0 3 0 2 0 5 4 3 3 3 0 5 4 4 1 1 0 0 2 5 4 3 3 0 3 2 1 5 4 3 3 5 2 4 3 0 4 5 3 5 0 1 1 1 4 1 1 3 0 3 5 3 0 0 3 4 2 0 0 5 0 5 5 1...

output:

16618 0

result:

ok single line: '16618 0'

Test #187:

score: 19
Accepted
time: 32ms
memory: 11084kb

input:

100000 24306
2 0 3 1 5 3 3 3 2 3 5 1 1 5 2 1 5 2 5 0 5 0 3 2 1 1 3 5 5 5 0 1 2 1 2 3 5 4 0 4 3 1 2 1 2 1 4 1 2 5 0 1 0 1 3 4 0 4 1 2 3 3 5 1 5 5 4 2 4 0 2 1 2 5 5 1 4 4 3 2 4 1 1 2 1 1 0 1 4 0 0 2 5 3 3 2 5 4 5 4 1 0 2 2 1 4 3 5 2 0 1 0 3 3 3 1 4 1 1 4 2 2 4 2 2 0 2 1 0 0 3 2 0 3 1 1 0 1 3 0 2 3 3 2...

output:

16589 0

result:

ok single line: '16589 0'

Test #188:

score: 19
Accepted
time: 38ms
memory: 13552kb

input:

100000 46326
2 3 2 2 3 0 3 3 0 0 0 2 1 3 2 4 2 3 4 0 3 3 4 0 1 3 5 2 2 0 0 0 0 1 0 5 3 0 0 4 1 4 4 1 2 3 5 0 0 5 5 3 1 3 0 1 3 4 5 4 4 3 1 5 1 5 4 5 1 0 2 5 2 1 3 0 4 1 4 5 2 3 1 5 3 3 0 0 2 1 2 0 4 2 4 3 2 0 1 4 3 5 2 2 3 4 1 0 3 0 2 4 2 3 1 4 5 5 0 3 3 4 2 1 0 5 1 1 4 2 4 2 0 0 3 1 2 3 2 3 1 1 1 1...

output:

16812 0

result:

ok single line: '16812 0'

Test #189:

score: 19
Accepted
time: 34ms
memory: 11136kb

input:

100000 19185
2 2 5 0 0 2 5 1 5 0 2 3 4 4 2 0 4 3 3 5 4 1 5 3 2 2 0 3 2 3 1 4 5 5 1 4 5 0 4 4 4 0 0 1 1 4 5 0 5 5 5 4 2 4 2 2 0 4 1 4 2 2 5 4 5 5 5 2 2 0 0 2 2 3 0 4 0 4 4 0 0 5 5 4 3 3 3 4 4 4 0 2 0 1 5 3 3 5 2 1 5 0 5 0 5 4 0 2 5 2 4 5 1 2 0 1 0 5 0 4 3 0 0 2 3 2 1 0 2 5 5 3 4 1 4 4 4 1 3 3 2 1 0 1...

output:

16791 0

result:

ok single line: '16791 0'

Test #190:

score: 19
Accepted
time: 32ms
memory: 12788kb

input:

100000 30966
2 2 3 4 5 0 5 1 0 2 0 4 0 3 2 0 1 3 1 2 0 0 3 2 3 1 5 3 0 0 5 3 4 3 4 3 5 2 5 1 4 5 0 3 5 5 5 0 1 1 3 4 2 5 2 1 4 3 4 1 0 5 5 1 0 3 0 4 3 1 4 3 2 3 3 4 1 0 1 1 0 3 0 4 4 3 4 3 5 2 1 1 0 0 4 0 1 3 5 3 5 5 1 1 5 0 5 1 1 2 5 1 3 3 3 3 0 5 5 2 2 3 2 2 0 5 3 2 1 0 3 5 1 0 0 3 5 1 5 3 1 5 5 2...

output:

16696 0

result:

ok single line: '16696 0'

Test #191:

score: 19
Accepted
time: 29ms
memory: 10616kb

input:

100000 60948
2 5 1 3 4 1 1 2 3 5 1 0 4 3 5 1 0 1 3 2 1 3 4 5 5 5 3 4 5 1 5 0 1 5 4 3 0 0 0 1 3 4 4 2 1 0 2 4 1 0 3 0 3 3 2 4 1 0 1 4 3 3 2 0 1 2 2 0 2 4 1 4 2 2 1 5 2 4 1 0 3 5 2 2 4 3 2 3 5 0 4 4 5 1 4 0 2 0 5 1 3 0 3 2 3 4 3 3 0 2 1 2 3 1 4 3 4 5 1 2 0 5 5 1 2 1 1 1 5 0 4 0 0 3 3 4 3 4 4 5 4 1 4 0...

output:

16701 0

result:

ok single line: '16701 0'

Test #192:

score: 19
Accepted
time: 5ms
memory: 10308kb

input:

10000 4552
0 2 1 3 1 1 2 1 2 1 3 1 2 3 2 3 1 1 2 2 3 1 1 1 2 2 1 3 3 3 1 1 2 3 1 1 1 2 1 3 1 3 2 2 1 2 2 2 2 2 3 1 3 2 1 1 2 2 3 2 1 3 3 1 3 3 3 1 1 2 3 2 1 3 1 1 2 2 3 2 3 1 3 2 1 1 1 3 3 3 3 3 3 3 2 1 1 2 3 3 2 2 3 1 3 3 1 3 2 1 2 1 1 1 1 1 1 3 2 2 2 3 1 1 2 3 3 1 3 1 2 3 1 3 2 1 3 1 3 2 3 2 2 1 1...

output:

3031 1057

result:

ok single line: '3031 1057'

Test #193:

score: 19
Accepted
time: 50ms
memory: 14548kb

input:

100000 14964
0 3 2 3 2 3 2 2 1 3 1 1 1 3 3 1 1 1 2 2 1 1 1 1 1 2 1 3 2 1 2 1 1 1 3 2 2 1 2 3 3 1 1 2 1 2 3 2 2 2 3 1 1 2 3 2 3 1 1 2 2 3 2 1 3 1 1 3 3 3 1 2 3 3 1 2 2 2 2 3 1 1 2 2 3 2 3 3 1 2 3 1 1 3 3 3 2 1 3 3 3 3 3 2 3 2 3 3 2 3 2 1 1 2 2 2 3 1 1 3 3 2 2 3 3 2 3 3 2 3 3 3 2 3 1 3 2 1 2 3 1 3 3 3...

output:

33011 12955

result:

ok single line: '33011 12955'

Test #194:

score: 19
Accepted
time: 30ms
memory: 15532kb

input:

99981 9999
0 1 1 2 2 1 2 2 1 1 1 1 1 1 1 1 2 1 2 1 1 3 3 4 3 4 4 3 3 3 3 4 3 4 3 3 3 3 4 3 4 5 6 5 6 6 5 5 6 6 5 5 5 6 5 5 5 5 5 5 6 8 8 7 7 7 8 7 8 7 8 8 7 7 7 7 8 8 7 7 8 10 9 9 10 10 9 9 10 9 10 9 10 10 10 10 9 10 9 10 9 11 11 11 11 11 11 11 12 12 11 12 12 12 11 11 11 11 11 12 11 13 14 14 14 13 1...

output:

10 0

result:

ok single line: '10 0'

Test #195:

score: 19
Accepted
time: 2ms
memory: 9744kb

input:

5 3
0 1 2 2 1
0
1
2
3

output:

2 0

result:

ok single line: '2 0'

Test #196:

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

input:

4 2
0 1 0 0
0
0
1

output:

3 0

result:

ok single line: '3 0'

Test #197:

score: 19
Accepted
time: 1ms
memory: 7684kb

input:

9 3
0 0 2 1 2 0 2 1 2
4
8
1
0
4
1
0
7

output:

4 2

result:

ok single line: '4 2'

Test #198:

score: 19
Accepted
time: 2ms
memory: 9784kb

input:

8 3
0 2 1 2 2 1 1 1
6
3
0
6
3
0
3

output:

3 2

result:

ok single line: '3 2'

Extra Test:

score: 0
Extra Test Passed