QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#866811#8811. Heat Strokelgvc45 302ms1600464kbC++233.0kb2025-01-22 19:30:482025-01-22 19:30:49

Judging History

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

  • [2025-01-22 19:30:49]
  • 评测
  • 测评结果:45
  • 用时:302ms
  • 内存:1600464kb
  • [2025-01-22 19:30:48]
  • 提交

answer

#include <bits/stdc++.h>
//0 qian j ge
//1 hou j ge
#define INF 0x3f3f3f3f
int N,L,va[8009],c[8009],la[8009][8009],vc[70000009][2],su[8009],v2[70000009][2],
su2[8009],ff[8009][8009];
std::vector<int> t[8009];
int sv2(int n,int x,int y,int op);
int sv(int n,int x,int y,int op);
int fd(int n,int x,int y,int op) {
	int a=sv(n,x,y,op);
	if((n==N-1)||(x==c[n])) return a;
	int l1=0;
	if(x<c[n]) l1=t[n][x+1]-1;else l1=L;
	a=std::min(a,sv2(n,ff[n+1][l1],((op==0)?(y):(x-y)),op)+x);
	return a;
}
int sv2(int n,int x,int y,int op) {
	if(x<0) return INF;
	int id=x*(c[n]+1)+y+su[n-1];
	if(v2[id][op]!=-1) return v2[id][op];
	int ans=sv2(n,x-1,y,op);
	for(int xx=x;xx<=x;xx++) {
		int l2=0,l1=0;
		if(x<c[n]) l1=t[n][x+1]-1;else l1=L;
		if(xx<c[n+1]) l2=t[n+1][xx+1]-1;else l2=L;
		if(l2>l1) continue;
		int lim=l2;
		int tp1=la[lim][n],tp2=la[lim][n+1];
		int vv=va[n+1];
		if(op==1) vv-=std::min(y,tp1);
		else vv-=(std::max(tp1,y)-y);	
		if(vv<=0) {
			ans=std::min(ans,fd(n+1,xx,0,0));
		} else {
			int yy=vv;
			if(yy<=tp2) ans=std::min(ans,fd(n+1,xx,yy,0));	
			yy=vv+xx-std::min(xx,tp2);
			if(yy<=xx) ans=std::min(ans,fd(n+1,xx,yy,1));				
		}
	}
	return v2[id][op]=ans;
}
int sv(int n,int x,int y,int op) {
	int id=x*(c[n]+1)+y+su[n-1];
	if(n==N-1) {
		if(x<c[n]&&(x-y)<va[n+1]) return INF;
		return x;
	}
	if(vc[id][op]!=-1) {
		return vc[id][op];
	}
	int ans=INF;
	int limm=0;
//	if(x<c[n]) limm=std::max(c[n+1]-1,0);
	for(int xx=limm;xx<=c[n+1];xx++) {
		int l1=0,l2=0;
		if(xx<c[n+1]) l2=t[n+1][xx+1]-1;else l2=L;
		if(x<c[n]) l1=t[n][x+1]-1;else l1=L;
		int lim=std::min(l1,l2);
		int tp1=la[lim][n],tp2=la[lim][n+1];
		int vv=va[n+1];
		if(op==1) vv-=std::min(x-y,tp1);
		else vv-=(std::max(std::min(x,tp1),y)-y);	
		if((vv<=0)||(xx==c[n+1]&&x==c[n])) {
			ans=std::min(ans,fd(n+1,xx,0,0)+x);
		} else {
			int yy=vv;
			if(yy<=tp2) ans=std::min(ans,fd(n+1,xx,yy,0)+x);	
			yy=vv+xx-std::min(xx,tp2);
			if(yy<=xx) ans=std::min(ans,fd(n+1,xx,yy,1)+x);				
		}
	}
	return vc[id][op]=ans;
}
signed main(void) {
	memset(vc,-1,sizeof(vc));
	memset(v2,-1,sizeof(v2));
	scanf("%d",&N);
	for(int i=1;i<=N;i++) {
		scanf("%d",&va[i]);
		t[i].push_back(0);
	}
	scanf("%d",&L);
	for(int i=1;i<=L;i++) {
		int x;
		scanf("%d",&x);
		t[x].push_back(i);
		c[x]++;
		for(int j=1;j<=N;j++) {
			la[i][j]=la[i-1][j];
		}
		la[i][x]=t[x].size()-1;
	}
	for(int i=1;i<=N;i++) {
		int la=0;
		for(int j=0;j<=c[i];j++) {
			int l2=0;
			if(j<c[i]) l2=t[i][j+1]-1;else l2=L;
			for(int k=la;k<=l2;k++) {
				ff[i][j]=j-1;
			}
			la=l2+1;
		}
	}
	for(int i=1;i<=N;i++) {
		su[i]=su[i-1]+(c[i]+1)*(c[i]+1);
	}
	for(int i=1;i<=N;i++) {
		su2[i]=su2[i-1]+(c[i]+1);
	}
	int ans=0x3f3f3f3f;
	for(int i=0;i<=c[1];i++) {
		for(int j=0;j<=i&&j<=va[1];j++) {
			if((i==c[1])||(j==va[1])) ans=std::min(ans,fd(1,i,j,0));
			if((i==c[1])||(j==va[1])) ans=std::min(ans,fd(1,i,j,1));
		}
	}
//	printf("%d\n",sv(4,0,0,0));
	printf("%d",L-ans);
}

詳細信息

Subtask #1:

score: 6
Accepted

Test #1:

score: 6
Accepted
time: 44ms
memory: 1099592kb

input:

2
0 0
1
1

output:

1

result:

ok single line: '1'

Test #2:

score: 6
Accepted
time: 36ms
memory: 1101488kb

input:

2
0 1
1
1

output:

0

result:

ok single line: '0'

Test #3:

score: 6
Accepted
time: 35ms
memory: 1099596kb

input:

2
1 0
1
1

output:

0

result:

ok single line: '0'

Test #4:

score: 6
Accepted
time: 39ms
memory: 1099588kb

input:

2
1 1
1
1

output:

0

result:

ok single line: '0'

Test #5:

score: 6
Accepted
time: 29ms
memory: 1099592kb

input:

2
2 2
1
1

output:

0

result:

ok single line: '0'

Test #6:

score: 6
Accepted
time: 39ms
memory: 1101656kb

input:

2
1 1
2
1 1

output:

0

result:

ok single line: '0'

Test #7:

score: 6
Accepted
time: 34ms
memory: 1099592kb

input:

2
2 2
2
1 1

output:

0

result:

ok single line: '0'

Test #8:

score: 6
Accepted
time: 28ms
memory: 1101656kb

input:

2
3 3
2
1 1

output:

0

result:

ok single line: '0'

Test #9:

score: 6
Accepted
time: 44ms
memory: 1118008kb

input:

2
298 299
600
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

3

result:

ok single line: '3'

Test #10:

score: 6
Accepted
time: 38ms
memory: 1210232kb

input:

2
1749 1749
3500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

2

result:

ok single line: '2'

Test #11:

score: 6
Accepted
time: 55ms
memory: 1347604kb

input:

2
3999 3999
8000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

2

result:

ok single line: '2'

Test #12:

score: 6
Accepted
time: 38ms
memory: 1349528kb

input:

2
1 1
8000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

7998

result:

ok single line: '7998'

Test #13:

score: 6
Accepted
time: 35ms
memory: 1349528kb

input:

2
0 0
8000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

8000

result:

ok single line: '8000'

Test #14:

score: 6
Accepted
time: 40ms
memory: 1099552kb

input:

3
0 1 1
2
1 2

output:

0

result:

ok single line: '0'

Test #15:

score: 6
Accepted
time: 32ms
memory: 1099548kb

input:

3
1 1 1
3
1 2 2

output:

1

result:

ok single line: '1'

Test #16:

score: 6
Accepted
time: 29ms
memory: 1099392kb

input:

3
1 2 0
3
1 1 2

output:

1

result:

ok single line: '1'

Test #17:

score: 6
Accepted
time: 36ms
memory: 1099464kb

input:

3
1 2 0
3
1 2 2

output:

1

result:

ok single line: '1'

Test #18:

score: 6
Accepted
time: 35ms
memory: 1099596kb

input:

3
1 3 0
4
1 1 1 2

output:

1

result:

ok single line: '1'

Test #19:

score: 6
Accepted
time: 38ms
memory: 1099596kb

input:

4
0 2 1 1
4
1 1 2 3

output:

0

result:

ok single line: '0'

Test #20:

score: 6
Accepted
time: 28ms
memory: 1101652kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
33
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17

output:

15

result:

ok single line: '15'

Test #21:

score: 6
Accepted
time: 59ms
memory: 1457964kb

input:

8000
0 2 0 0 0 0 0 0 1 0 0 2 1 1 0 1 1 0 2 2 0 0 0 1 1 0 0 0 0 1 1 1 2 3 0 2 2 0 0 1 0 1 2 1 1 0 1 1 0 0 0 0 1 1 0 1 0 0 0 1 1 0 0 1 0 1 0 0 0 0 0 0 1 0 0 0 1 0 1 2 0 0 0 0 0 1 0 1 1 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 2 2 0 3 2 0 0 0 0 0 1 1 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 1 3 0...

output:

843

result:

ok single line: '843'

Test #22:

score: 6
Accepted
time: 82ms
memory: 1599956kb

input:

8000
1 0 1 2 3 2 1 1 1 1 2 4 1 3 2 2 0 3 2 0 1 1 1 1 0 0 0 0 1 0 4 4 3 0 0 0 2 1 0 0 0 0 0 0 0 0 0 2 0 3 3 0 2 0 0 0 2 0 0 2 2 0 1 5 3 0 0 3 0 1 1 2 1 1 2 2 0 0 3 0 0 1 0 0 1 0 1 1 2 3 0 0 1 4 1 2 1 1 2 1 0 0 0 2 2 1 1 0 1 1 1 1 1 0 0 0 0 0 1 0 1 0 3 0 1 1 0 1 1 1 0 0 2 1 1 3 3 0 1 0 0 4 1 0 0 1 0 0...

output:

1799

result:

ok single line: '1799'

Test #23:

score: 6
Accepted
time: 67ms
memory: 1600336kb

input:

8000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

2146

result:

ok single line: '2146'

Test #24:

score: 6
Accepted
time: 73ms
memory: 1600464kb

input:

8000
8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 ...

output:

0

result:

ok single line: '0'

Test #25:

score: 6
Accepted
time: 52ms
memory: 1461144kb

input:

3579
0 3 5 0 3 0 1 6 5 1 1 7 0 1 2 0 0 4 3 1 0 4 2 8 2 5 2 2 3 2 0 0 1 4 2 2 2 4 2 0 4 1 0 4 0 5 3 4 1 8 6 0 0 0 2 4 1 2 7 8 2 2 3 5 0 1 0 0 2 1 4 6 4 4 1 1 4 2 1 0 3 3 0 4 4 1 1 6 0 1 2 0 0 1 3 7 3 2 1 3 2 2 1 0 0 0 1 5 4 4 3 0 3 4 4 3 2 1 2 2 1 1 2 1 1 3 11 1 2 0 3 0 4 1 3 3 6 2 1 7 6 2 0 1 3 0 1 ...

output:

1634

result:

ok single line: '1634'

Test #26:

score: 6
Accepted
time: 52ms
memory: 1392920kb

input:

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

output:

1608

result:

ok single line: '1608'

Test #27:

score: 6
Accepted
time: 42ms
memory: 1351736kb

input:

68
38 219 171 204 116 205 90 225 221 43 74 153 142 147 151 133 65 189 196 4 91 93 215 80 213 25 180 16 24 143 60 22 129 190 59 70 242 53 205 95 212 26 69 123 50 47 205 5 62 154 78 203 48 99 118 7 25 151 222 141 151 143 90 90 141 228 193 75
8000
1 1 1 1 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:

1018

result:

ok single line: '1018'

Test #28:

score: 6
Accepted
time: 302ms
memory: 1347852kb

input:

3
137 4887 1630
8000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

1483

result:

ok single line: '1483'

Test #29:

score: 6
Accepted
time: 38ms
memory: 1349524kb

input:

3
1 7999 0
8000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

1

result:

ok single line: '1'

Test #30:

score: 6
Accepted
time: 39ms
memory: 1103576kb

input:

4
0 50 50 0
100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

output:

0

result:

ok single line: '0'

Test #31:

score: 6
Accepted
time: 285ms
memory: 1349772kb

input:

4
0 4000 4000 0
8000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

0

result:

ok single line: '0'

Test #32:

score: 6
Accepted
time: 47ms
memory: 1362000kb

input:

800
0 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 0 17 0 18 0 19 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 2 0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 3 0 3 1 3 2 3 3 3 4 3 5 3 ...

output:

1330

result:

ok single line: '1330'

Subtask #2:

score: 7
Accepted

Test #33:

score: 7
Accepted
time: 46ms
memory: 1099592kb

input:

3
1 1 1
3
1 2 1

output:

1

result:

ok single line: '1'

Test #34:

score: 7
Accepted
time: 31ms
memory: 1099588kb

input:

3
1 1 1
3
2 1 2

output:

1

result:

ok single line: '1'

Test #35:

score: 7
Accepted
time: 45ms
memory: 1099588kb

input:

7
1 1 1 1 1 1 1
8
2 1 6 5 4 3 2 6

output:

3

result:

ok single line: '3'

Test #36:

score: 7
Accepted
time: 37ms
memory: 1101544kb

input:

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

output:

4

result:

ok single line: '4'

Test #37:

score: 7
Accepted
time: 38ms
memory: 1099588kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
13
13 17 13 9 15 4 12 11 12 7 5 15 1

output:

1

result:

ok single line: '1'

Test #38:

score: 7
Accepted
time: 36ms
memory: 1099464kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
15
17 12 6 3 15 17 3 10 6 12 15 17 11 12 14

output:

3

result:

ok single line: '3'

Test #39:

score: 7
Accepted
time: 43ms
memory: 1101680kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
16
16 11 13 10 5 3 10 6 13 16 16 2 14 9 9 3

output:

4

result:

ok single line: '4'

Test #40:

score: 7
Accepted
time: 38ms
memory: 1101612kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
17
12 5 4 1 10 6 8 8 16 6 12 14 7 14 17 12 9

output:

4

result:

ok single line: '4'

Test #41:

score: 7
Accepted
time: 36ms
memory: 1101700kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
18
14 9 3 16 9 2 2 9 4 10 12 17 13 10 10 10 3 11

output:

7

result:

ok single line: '7'

Test #42:

score: 7
Accepted
time: 35ms
memory: 1101656kb

input:

17
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
18
15 9 6 3 13 9 13 16 7 5 8 1 1 9 9 15 16 1

output:

5

result:

ok single line: '5'

Test #43:

score: 7
Accepted
time: 41ms
memory: 1099596kb

input:

16
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
18
13 4 8 8 13 8 1 15 3 6 4 8 6 4 12 9 15 14

output:

5

result:

ok single line: '5'

Test #44:

score: 7
Accepted
time: 31ms
memory: 1101660kb

input:

15
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
18
1 10 3 3 9 6 4 8 3 12 12 11 7 14 6 5 3 3

output:

6

result:

ok single line: '6'

Test #45:

score: 7
Accepted
time: 37ms
memory: 1101652kb

input:

13
1 1 1 1 1 1 1 1 1 1 1 1 1
18
11 5 4 8 12 2 1 3 8 8 9 4 12 7 12 3 6 6

output:

7

result:

ok single line: '7'

Test #46:

score: 7
Accepted
time: 35ms
memory: 1101656kb

input:

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

output:

6

result:

ok single line: '6'

Test #47:

score: 7
Accepted
time: 38ms
memory: 1101656kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
18
1 5 7 11 13 17 2 4 8 10 14 16 1 5 7 11 13 17

output:

6

result:

ok single line: '6'

Test #48:

score: 7
Accepted
time: 34ms
memory: 1099588kb

input:

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

output:

5

result:

ok single line: '5'

Test #49:

score: 7
Accepted
time: 42ms
memory: 1101696kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
18
1 1 2 4 5 4 7 8 8 11 10 10 14 13 14 17 17 16

output:

4

result:

ok single line: '4'

Test #50:

score: 7
Accepted
time: 41ms
memory: 1101660kb

input:

16
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
12
1 2 3 5 7 6 10 9 11 15 14 13

output:

1

result:

ok single line: '1'

Subtask #3:

score: 7
Accepted

Dependency #2:

100%
Accepted

Test #51:

score: 7
Accepted
time: 35ms
memory: 1101660kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
33
17 17 16 16 15 15 14 14 13 13 12 12 11 11 10 10 9 9 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1

output:

15

result:

ok single line: '15'

Test #52:

score: 7
Accepted
time: 45ms
memory: 1101656kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
20
16 6 17 10 14 2 12 6 12 16 9 16 1 1 8 16 15 1 5 6

output:

7

result:

ok single line: '7'

Test #53:

score: 7
Accepted
time: 40ms
memory: 1101716kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
23
6 4 16 11 16 17 7 15 7 14 11 16 16 17 17 17 15 15 17 12 5 14 7

output:

11

result:

ok single line: '11'

Test #54:

score: 7
Accepted
time: 38ms
memory: 1101652kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
26
1 1 11 15 12 16 15 5 12 12 10 10 5 3 12 11 8 15 12 8 7 10 3 4 15 15

output:

11

result:

ok single line: '11'

Test #55:

score: 7
Accepted
time: 37ms
memory: 1101660kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
29
5 14 2 14 12 11 1 6 13 9 14 1 16 1 2 16 11 3 6 3 12 6 16 8 7 3 15 6 2

output:

14

result:

ok single line: '14'

Test #56:

score: 7
Accepted
time: 35ms
memory: 1101656kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
32
10 14 1 6 9 8 3 12 4 2 16 5 14 13 13 6 3 13 11 13 8 1 15 13 2 3 8 14 13 1 15 9

output:

18

result:

ok single line: '18'

Test #57:

score: 7
Accepted
time: 29ms
memory: 1101660kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
35
3 9 4 14 11 1 2 4 6 14 12 7 8 14 11 15 7 10 2 9 2 3 11 3 2 7 3 5 16 3 3 11 9 17 12

output:

18

result:

ok single line: '18'

Test #58:

score: 7
Accepted
time: 35ms
memory: 1103700kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
38
7 14 9 15 8 7 6 6 10 15 10 16 6 13 11 8 15 11 12 16 2 5 13 10 3 4 14 4 12 8 8 17 11 5 9 5 12 16

output:

22

result:

ok single line: '22'

Test #59:

score: 7
Accepted
time: 38ms
memory: 1101528kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
41
15 16 17 13 2 16 3 2 10 3 16 11 9 13 1 3 16 2 3 17 10 12 8 2 9 2 8 17 4 8 10 1 1 13 7 6 14 13 2 9 1

output:

23

result:

ok single line: '23'

Test #60:

score: 7
Accepted
time: 34ms
memory: 1103704kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
3 1 15 2 12 2 12 16 8 6 9 14 15 16 17 13 8 8 9 14 17 8 17 2 3 14 3 10 17 7 11 1 17 1 17 9 14 6 1 2 6 9 7 11 7 6 15 9 4 14 10 3 17 15 14 4 8 16 10 11 15 9 15 17 15 7 12 7 7 4 9 4 14 14 6 14 10 7 15 7 14 4 1 5 17 4 3 4 8 4 1 7 9 1 7 9 12 9 17 2

output:

82

result:

ok single line: '82'

Test #61:

score: 7
Accepted
time: 36ms
memory: 1101584kb

input:

17
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
24
1 2 1 3 4 3 5 6 5 7 8 7 9 10 9 11 12 11 13 14 13 15 16 15

output:

8

result:

ok single line: '8'

Test #62:

score: 7
Accepted
time: 38ms
memory: 1101656kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
32
2 1 3 2 4 3 5 4 6 5 7 6 8 7 9 8 10 9 11 10 12 11 13 12 14 13 15 14 16 15 17 16

output:

15

result:

ok single line: '15'

Test #63:

score: 7
Accepted
time: 37ms
memory: 1101652kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
32
2 16 1 17 3 15 2 16 4 14 3 15 5 13 4 14 6 12 5 13 7 11 6 12 8 10 7 11 9 8 10 9

output:

16

result:

ok single line: '16'

Test #64:

score: 7
Accepted
time: 47ms
memory: 1101504kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
32
9 10 8 9 11 7 10 8 12 6 11 7 13 5 12 6 14 4 13 5 15 3 14 4 16 2 15 3 17 1 16 2

output:

15

result:

ok single line: '15'

Test #65:

score: 7
Accepted
time: 45ms
memory: 1101640kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
32
9 10 8 9 11 7 10 8 12 6 11 7 13 5 12 6 14 4 13 5 15 3 14 4 1 16 2 15 3 17 16 2

output:

16

result:

ok single line: '16'

Test #66:

score: 7
Accepted
time: 30ms
memory: 1101660kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
32
1 17 2 16 3 15 4 14 5 13 6 12 7 11 8 10 9 1 17 2 16 3 15 4 14 5 13 6 12 7 11 8

output:

15

result:

ok single line: '15'

Subtask #4:

score: 25
Accepted

Dependency #3:

100%
Accepted

Test #67:

score: 25
Accepted
time: 39ms
memory: 1105756kb

input:

100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
50
10 18 8 18 88 37 61 48 39 35 74 58 24 43 99 70 8 9 48 88 26 30 26 37 99 29 25 1 57 34 40 98 2...

output:

7

result:

ok single line: '7'

Test #68:

score: 25
Accepted
time: 40ms
memory: 1105748kb

input:

100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
60
28 72 39 42 9 65 38 46 4 19 69 70 94 31 20 55 9 42 54 72 49 20 71 38 34 14 22 94 16 26 5 55 8...

output:

12

result:

ok single line: '12'

Test #69:

score: 25
Accepted
time: 45ms
memory: 1105800kb

input:

100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
70
73 38 10 32 90 75 51 10 58 68 78 88 19 1 25 90 31 42 53 17 90 19 35 90 24 18 88 71 66 73 54 8...

output:

12

result:

ok single line: '12'

Test #70:

score: 25
Accepted
time: 36ms
memory: 1105840kb

input:

100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
80
3 56 58 99 25 30 32 62 45 58 15 95 6 45 13 21 89 45 14 65 13 6 35 30 31 52 93 55 66 83 4 79 7...

output:

20

result:

ok single line: '20'

Test #71:

score: 25
Accepted
time: 32ms
memory: 1107900kb

input:

100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
90
8 76 98 17 85 41 9 75 61 79 57 50 59 43 80 80 23 57 89 64 13 49 93 14 50 1 46 47 85 78 87 3 9...

output:

26

result:

ok single line: '26'

Test #72:

score: 25
Accepted
time: 32ms
memory: 1105752kb

input:

100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
74 8 70 56 3 97 4 87 6 56 3 57 38 67 79 58 13 48 18 89 5 59 34 21 79 59 29 58 86 19 42 95 79...

output:

33

result:

ok single line: '33'

Test #73:

score: 25
Accepted
time: 30ms
memory: 1105944kb

input:

90
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
27 4 2 53 45 51 18 68 73 22 4 15 15 75 82 16 24 34 77 13 85 9 40 40 71 7 55 17 61 72 40 43 57 49 84 28 85 25 44 8...

output:

33

result:

ok single line: '33'

Test #74:

score: 25
Accepted
time: 33ms
memory: 1105720kb

input:

80
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
69 58 66 69 2 32 59 79 2 47 56 40 1 79 77 62 56 45 34 32 14 19 44 19 18 65 9 74 47 47 78 24 35 8 3 73 56 9 38 17 10 47 11 67 36 18 34...

output:

38

result:

ok single line: '38'

Test #75:

score: 25
Accepted
time: 31ms
memory: 1105976kb

input:

70
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
41 3 68 43 52 67 22 16 8 56 7 64 32 61 16 33 36 49 30 32 29 13 37 46 3 12 37 67 59 60 64 37 69 61 30 68 28 37 66 42 3 32 49 6 26 27 50 68 58 56 43 60 8 6...

output:

41

result:

ok single line: '41'

Test #76:

score: 25
Accepted
time: 37ms
memory: 1105924kb

input:

60
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
14 42 8 9 22 15 22 15 59 59 5 12 44 38 26 35 2 4 38 25 17 48 1 7 23 15 18 41 30 59 42 4 3 40 29 25 26 57 45 28 51 25 49 1 52 49 59 51 1 34 32 38 13 29 53 16 1 11 6 59 53 8 3...

output:

49

result:

ok single line: '49'

Test #77:

score: 25
Accepted
time: 32ms
memory: 1103832kb

input:

50
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
44 32 27 37 12 4 35 2 17 12 13 17 15 48 49 34 12 46 26 16 5 22 15 40 12 13 22 25 24 13 17 49 27 36 5 17 41 35 16 22 2 38 11 25 37 4 17 18 48 23 31 39 44 3 37 29 44 45 1 36 2 6 49 3 5 24 40 41 2...

output:

54

result:

ok single line: '54'

Test #78:

score: 25
Accepted
time: 32ms
memory: 1105988kb

input:

67
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
99
1 2 1 3 4 3 5 6 5 7 8 7 9 10 9 11 12 11 13 14 13 15 16 15 17 18 17 19 20 19 21 22 21 23 24 23 25 26 25 27 28 27 29 30 29 31 32 31 33 34 33 35 36 35 37 38 37 39 ...

output:

33

result:

ok single line: '33'

Test #79:

score: 25
Accepted
time: 40ms
memory: 1105804kb

input:

99
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
99
1 5 7 11 13 17 19 23 25 29 31 35 37 41 43 47 49 53 55 59 61 65 67 71 73 77 79 83 85 89 91 95 97 ...

output:

33

result:

ok single line: '33'

Test #80:

score: 25
Accepted
time: 33ms
memory: 1105936kb

input:

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

output:

33

result:

ok single line: '33'

Test #81:

score: 25
Accepted
time: 37ms
memory: 1105732kb

input:

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

output:

49

result:

ok single line: '49'

Test #82:

score: 25
Accepted
time: 39ms
memory: 1103832kb

input:

52
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
2 50 1 51 3 49 2 50 4 48 3 49 5 47 4 48 6 46 5 47 7 45 6 46 8 44 7 45 9 43 8 44 10 42 9 43 11 41 10 42 12 40 11 41 13 39 12 40 14 38 13 39 15 37 14 38 16 36 15 37 17 35 16 36 18 34 17 35 19...

output:

50

result:

ok single line: '50'

Test #83:

score: 25
Accepted
time: 38ms
memory: 1103620kb

input:

52
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
26 27 25 26 28 24 27 25 29 23 28 24 30 22 29 23 31 21 30 22 32 20 31 21 33 19 32 20 34 18 33 19 35 17 34 18 36 16 35 17 37 15 36 16 38 14 37 15 39 13 38 14 40 12 39 13 41 11 40 12 42 10 41 ...

output:

49

result:

ok single line: '49'

Test #84:

score: 25
Accepted
time: 36ms
memory: 1103828kb

input:

52
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
26 27 25 26 28 24 27 25 29 23 28 24 30 22 29 23 31 21 30 22 32 20 31 21 33 19 32 20 34 18 33 19 35 17 34 18 36 16 35 17 37 15 36 16 38 14 37 15 39 13 38 14 40 12 39 13 41 11 40 12 42 10 41 ...

output:

50

result:

ok single line: '50'

Test #85:

score: 25
Accepted
time: 34ms
memory: 1103756kb

input:

52
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
1 51 2 50 3 49 4 48 5 47 6 46 7 45 8 44 9 43 10 42 11 41 12 40 13 39 14 38 15 37 16 36 17 35 18 34 19 33 20 32 21 31 22 30 23 29 24 28 25 27 26 1 51 2 50 3 49 4 48 5 47 6 46 7 45 8 44 9 43 ...

output:

49

result:

ok single line: '49'

Test #86:

score: 25
Accepted
time: 27ms
memory: 1103808kb

input:

42
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
56
1 1 1 2 4 4 5 4 7 7 8 8 10 11 10 10 13 14 13 14 16 17 17 16 19 20 20 20 23 22 22 22 26 25 25 26 29 28 29 28 32 31 32 32 35 35 34 34 38 38 37 38 41 41 41 40

output:

18

result:

ok single line: '18'

Test #87:

score: 25
Accepted
time: 32ms
memory: 1105936kb

input:

84
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
84
1 1 2 3 5 5 7 6 9 10 9 11 13 14 14 15 17 18 19 18 21 22 23 23 25 27 26 25 29 31 30 30 33 35 34 35 37 39 39 38 42 41 41 43 46 4...

output:

19

result:

ok single line: '19'

Test #88:

score: 25
Accepted
time: 38ms
memory: 1103804kb

input:

40
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
32
1 2 3 4 6 7 9 8 11 13 12 14 16 19 18 17 22 21 23 24 27 26 29 28 33 32 31 34 39 38 37 36

output:

4

result:

ok single line: '4'

Test #89:

score: 25
Accepted
time: 35ms
memory: 1105844kb

input:

96
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
80
1 2 3 4 5 7 8 9 11 10 13 14 16 15 17 19 20 23 22 21 25 27 26 28 29 31 33 32 35 34 37 40 39 38 41 43 47...

output:

11

result:

ok single line: '11'

Subtask #5:

score: 0
Wrong Answer

Dependency #4:

100%
Accepted

Test #90:

score: 25
Accepted
time: 33ms
memory: 1101656kb

input:

3
1 1 0
2
2 1

output:

0

result:

ok single line: '0'

Test #91:

score: 25
Accepted
time: 31ms
memory: 1099592kb

input:

3
0 0 0
3
1 2 1

output:

3

result:

ok single line: '3'

Test #92:

score: 25
Accepted
time: 35ms
memory: 1101524kb

input:

3
0 2 1
3
2 1 1

output:

1

result:

ok single line: '1'

Test #93:

score: 25
Accepted
time: 34ms
memory: 1101672kb

input:

4
1 1 2 0
4
3 3 2 1

output:

0

result:

ok single line: '0'

Test #94:

score: 25
Accepted
time: 40ms
memory: 1099592kb

input:

4
1 2 2 1
5
2 2 1 3 2

output:

1

result:

ok single line: '1'

Test #95:

score: 25
Accepted
time: 28ms
memory: 1099592kb

input:

4
1 2 2 1
5
3 1 2 2 2

output:

1

result:

ok single line: '1'

Test #96:

score: 25
Accepted
time: 33ms
memory: 1099592kb

input:

4
1 2 2 1
5
1 3 2 2 2

output:

1

result:

ok single line: '1'

Test #97:

score: 25
Accepted
time: 42ms
memory: 1099592kb

input:

4
1 2 2 0
6
2 2 3 2 1 2

output:

2

result:

ok single line: '2'

Test #98:

score: 25
Accepted
time: 39ms
memory: 1099592kb

input:

4
0 2 2 1
6
2 2 1 2 3 2

output:

2

result:

ok single line: '2'

Test #99:

score: 25
Accepted
time: 36ms
memory: 1105856kb

input:

100
2 0 1 1 0 2 1 0 1 0 0 0 0 0 0 0 0 1 0 1 1 1 0 0 0 0 1 0 0 2 2 3 3 0 0 0 0 0 0 1 1 0 0 0 2 2 2 0 0 0 0 2 1 0 3 3 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 3 3 1 0 1 1 0 0 1 1 0 1 0 0 0 1 0 0 2 0 0 0 0 1 1 2 0
60
91 70 82 1 20 65 5 76 90 55 86 6 3 52 9 55 58 89 32 43 22 85 52 72 68 32 32 46 74 31 22 26 67...

output:

18

result:

ok single line: '18'

Test #100:

score: 25
Accepted
time: 32ms
memory: 1107920kb

input:

100
0 1 2 2 0 2 0 2 1 0 3 2 2 0 0 0 2 4 0 1 2 0 0 0 0 0 1 0 0 0 2 3 2 0 1 1 1 1 1 0 0 3 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 3 0 0 0 2 0 0 1 0 0 1 0 2 1 0 2 0 4 3 1 0 0 0 2 1 2 1 0 0 1 2 1 2 1 0 0 0
80
56 48 35 10 4 81 37 42 18 20 27 90 96 76 86 17 63 67 64 60 65 71 41 89 94 39 61 80 87 86 75 8...

output:

17

result:

ok single line: '17'

Test #101:

score: 25
Accepted
time: 43ms
memory: 1107804kb

input:

100
3 2 0 0 1 0 1 5 3 0 0 1 2 1 3 1 0 0 3 2 0 0 0 2 2 0 0 2 1 3 0 1 0 0 0 0 1 2 0 0 0 1 0 1 1 0 1 1 0 0 2 1 0 1 0 1 1 1 2 1 3 2 0 0 2 0 1 1 0 0 1 0 1 1 2 3 2 3 1 0 1 2 2 3 1 2 1 1 1 1 1 0 0 0 0 0 2 1 1 1
100
87 85 37 97 25 85 91 97 84 21 51 61 15 19 5 27 58 73 99 81 59 56 75 38 81 47 40 29 65 99 64 ...

output:

22

result:

ok single line: '22'

Test #102:

score: 25
Accepted
time: 34ms
memory: 1105628kb

input:

100
8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8...

output:

0

result:

ok single line: '0'

Test #103:

score: 25
Accepted
time: 37ms
memory: 1105788kb

input:

80
0 0 1 0 0 0 2 0 1 1 1 0 1 1 0 3 0 1 0 1 2 0 1 1 0 2 4 1 1 0 1 3 0 3 1 0 2 2 0 0 4 1 0 2 3 1 1 0 1 3 2 2 0 3 2 1 5 2 1 1 4 0 2 5 2 1 0 1 1 1 1 0 0 3 2 1 0 2 1 0
100
18 11 10 51 33 6 60 64 62 38 77 46 56 24 78 45 54 64 26 44 30 2 24 25 33 72 63 73 64 40 36 15 66 7 41 20 31 74 6 76 18 49 14 12 36 69...

output:

20

result:

ok single line: '20'

Test #104:

score: 25
Accepted
time: 45ms
memory: 1105964kb

input:

60
0 0 3 7 7 1 0 1 7 0 0 0 1 2 1 2 4 0 1 1 2 0 2 4 2 3 0 0 3 0 6 1 0 0 1 1 4 6 1 0 2 2 0 3 1 1 1 0 0 0 3 1 0 0 1 0 0 1 1 1
100
13 36 4 8 37 58 2 17 31 36 43 12 41 38 55 37 2 32 50 25 2 23 6 43 16 4 29 4 36 30 39 30 41 23 28 46 37 7 2 25 38 12 43 18 8 9 30 32 51 50 31 56 23 56 34 17 21 24 5 50 4 54 4...

output:

26

result:

ok single line: '26'

Test #105:

score: 25
Accepted
time: 41ms
memory: 1103700kb

input:

50
1 0 2 3 2 2 0 3 5 2 3 0 2 4 2 2 1 3 0 0 2 3 0 1 4 0 2 2 1 0 1 2 7 8 4 4 4 1 0 3 2 3 0 0 3 3 0 3 3 2
100
4 30 33 19 6 37 39 43 21 38 36 8 3 45 5 13 10 26 35 17 34 48 25 32 46 40 9 14 1 3 37 27 34 35 14 33 34 8 10 47 47 40 49 4 14 35 44 7 25 25 19 42 12 44 37 11 18 9 18 7 12 47 34 25 15 9 28 43 40 ...

output:

20

result:

ok single line: '20'

Test #106:

score: 25
Accepted
time: 34ms
memory: 1103832kb

input:

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

output:

10

result:

ok single line: '10'

Test #107:

score: 0
Wrong Answer
time: 37ms
memory: 1103708kb

input:

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

output:

34

result:

wrong answer 1st lines differ - expected: '33', found: '34'

Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Skipped

Dependency #6:

0%

Subtask #8:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

0%