QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#472119#4925. Adjacent Pairszjh11451455 1985ms34800kbC++14994b2024-07-11 14:37:292024-07-11 14:37:30

Judging History

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

  • [2024-07-11 14:37:30]
  • 评测
  • 测评结果:55
  • 用时:1985ms
  • 内存:34800kb
  • [2024-07-11 14:37:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
long long t,n;
long long a[N],c1[N],c2[N],id[N];
bool cmp(long long x,long long y)
{
	return c2[x]>c2[y];
}
void solve()
{
	cin>>n;
	memset(c1,0,sizeof(c1));
	memset(c2,0,sizeof(c2));
	for(int i=1;i<=n+1;i++) id[i]=i;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		i&1?++c1[a[i]]:++c2[a[i]];
	}
	map<pair<int,int>,int> mp;
	sort(id+1,id+1+n,cmp);
	for(int l=1,r;l<n;l=r)
	{
		r=l+1;
		int x=a[l],y=a[r];
		if(l%2==0) swap(x,y);
		while(r<n)
		{
			if((r+1)%2==1&&a[r+1]!=x) break;
			if((r+1)%2==0&&a[r+1]!=y) break;
			r++;
		}
		mp[{x,y}]+=(r-l+1)>>1;
	} 
	long long ans=0;
	for(int i=1;i<n;i++)
	{
		int x=a[i],y=a[i+1];
		if(i%2==0) swap(x,y);
		ans=max(ans,c1[y]+c2[x]-mp[{x,y}]);
	}
	for(int i=1;i<=n+1;i++)
	{ 
		int t=1;
		while(mp[{id[t],i}]||i==id[t]) t++;
		ans=max(ans,c1[i]+c2[id[t]]);	
	}
	cout<<n-ans<<endl;
}
int main()
{
	cin>>t;
	while(t--) solve();
	return 0;
} 

详细

Subtask #1:

score: 20
Accepted

Test #1:

score: 20
Accepted
time: 1ms
memory: 7712kb

input:

2
5
4 5 2 4 5
2
1 2

output:

3
0

result:

ok 2 lines

Test #2:

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

input:

1
9
1 2 1 2 3 1 2 1 2

output:

6

result:

ok single line: '6'

Test #3:

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

input:

1
7
6 5 4 1 2 6 5

output:

5

result:

ok single line: '5'

Test #4:

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

input:

1
16
4 3 4 3 4 3 4 3 1 4 3 4 1 4 3 4

output:

10

result:

ok single line: '10'

Test #5:

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

input:

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

output:

9
9
9
9
9
9
9
9
10

result:

ok 9 lines

Test #6:

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

input:

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

output:

17
18
18
18
18

result:

ok 5 lines

Test #7:

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

input:

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

output:

47
48

result:

ok 2 lines

Test #8:

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

input:

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

output:

8
8
8
8
8
8
8
8
8
8

result:

ok 10 lines

Test #9:

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

input:

4
24
8 7 24 21 19 22 12 9 13 11 1 20 3 16 10 6 2 4 15 17 5 14 18 23
25
23 20 1 7 9 22 6 15 25 21 2 14 10 18 11 5 13 4 17 3 24 8 16 19 12
25
17 19 14 8 22 13 10 1 4 20 15 7 25 16 5 23 9 11 12 6 18 24 2 3 21
25
17 2 3 6 13 24 10 25 4 22 1 11 9 14 20 7 15 21 19 16 12 18 8 5 23

output:

22
23
23
23

result:

ok 4 lines

Test #10:

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

input:

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

output:

98

result:

ok single line: '98'

Test #11:

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

input:

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

output:

6
5
7
6
5
5
6
5
5
7

result:

ok 10 lines

Test #12:

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

input:

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

output:

15
15
12
15
12

result:

ok 5 lines

Test #13:

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

input:

2
49
8 43 31 29 46 29 32 49 32 19 31 12 44 12 9 49 43 49 43 23 8 2 8 2 5 7 13 25 7 25 7 25 4 25 36 28 36 19 40 19 40 19 30 19 47 40 24 31 9
50
15 46 35 30 35 29 27 29 50 43 47 38 40 38 18 27 24 49 7 49 24 44 4 19 30 24 1 25 1 50 7 38 12 15 50 48 1 27 29 21 46 31 46 41 6 41 50 1 50 32

output:

41
43

result:

ok 2 lines

Test #14:

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

input:

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

output:

6
7
6
6
4
6
8
7
7

result:

ok 9 lines

Test #15:

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

input:

4
24
21 15 5 22 13 14 13 21 18 6 18 6 18 4 19 4 19 10 5 9 21 9 12 24
25
8 14 15 14 15 14 18 17 18 17 21 19 25 1 9 1 15 4 15 4 23 13 19 15 19
25
25 20 15 12 20 12 6 23 25 12 8 15 12 7 20 14 6 12 11 25 8 23 6 8 23
25
7 24 21 17 15 16 17 16 9 21 4 24 15 23 20 17 18 23 3 21 3 7 20 18 5

output:

19
18
18
21

result:

ok 4 lines

Test #16:

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

input:

1
100
34 15 81 15 81 15 81 15 81 15 81 88 16 88 16 88 16 67 87 67 87 67 87 67 87 67 6 62 53 83 53 83 53 83 53 83 53 49 69 49 69 49 69 90 59 90 37 94 37 94 37 94 37 6 55 6 55 89 87 89 87 41 73 8 73 8 73 8 73 8 15 68 9 68 35 76 35 76 35 76 35 76 35 76 40 81 40 81 40 81 40 81 40 31 79 31 79 31 79 31

output:

89

result:

ok single line: '89'

Test #17:

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

input:

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

output:

5
5
5
5
5
5
5
5
5
5

result:

ok 10 lines

Test #18:

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

input:

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

output:

14
15
15
15
15

result:

ok 5 lines

Test #19:

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

input:

2
50
49 10 49 10 49 10 11 49 10 3 19 3 19 46 3 19 9 50 9 50 41 9 50 37 12 37 12 31 37 12 14 18 14 18 29 14 18 27 7 27 7 45 27 7 20 48 4 38 5 2
50
44 19 44 19 44 19 33 44 19 17 3 17 3 34 17 3 6 26 6 26 7 6 26 23 35 23 35 45 23 35 2 13 2 13 48 2 13 8 49 8 49 24 8 49 4 42 9 20 12 36

output:

45
45

result:

ok 2 lines

Test #20:

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

input:

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

output:

5
5
5
5
5
5
5
5
5
5

result:

ok 10 lines

Test #21:

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

input:

4
24
17 11 17 11 17 11 24 17 11 8 16 8 16 15 8 16 14 20 14 20 3 14 20 23
25
14 16 14 16 14 16 20 14 16 6 23 6 23 17 6 23 10 3 10 3 5 10 3 11 18
25
6 13 6 13 6 13 9 6 13 11 23 11 23 25 11 23 2 17 2 17 19 2 17 5 24
25
13 3 13 3 13 3 12 13 3 18 7 18 7 2 18 7 8 25 8 25 16 8 25 1 17

output:

19
20
20
20

result:

ok 4 lines

Test #22:

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

input:

1
99
26 90 26 90 26 90 13 26 90 3 63 3 63 94 3 63 25 5 25 5 21 25 5 29 30 29 30 85 29 30 69 82 69 82 22 69 82 88 97 88 97 42 88 97 62 66 62 66 72 62 66 73 28 73 28 24 73 28 92 47 92 47 80 92 47 51 38 51 38 23 51 38 14 84 14 84 11 14 84 18 43 18 43 55 18 43 19 49 19 49 99 19 49 8 91 34 17 9 70

output:

94

result:

ok single line: '94'

Test #23:

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

input:

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

output:

7
7
8
7
7
8
6
7
6

result:

ok 9 lines

Test #24:

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

input:

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

output:

15
16
15
16
16

result:

ok 5 lines

Test #25:

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

input:

2
50
37 28 35 42 1 30 21 22 29 34 46 27 22 10 27 22 49 36 37 33 19 46 2 15 47 31 43 31 43 31 43 31 43 31 43 31 43 1 31 43 31 43 31 43 31 43 31 43 31 43
50
23 14 9 13 18 16 35 25 41 43 50 40 50 39 6 39 30 20 49 11 14 7 17 42 4 17 23 17 23 17 23 17 23 17 23 17 23 1 17 23 17 23 17 23 17 23 17 23 17 23

output:

42
41

result:

ok 2 lines

Test #26:

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

input:

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

output:

6
7
7
7
6
7
7
6
7
6

result:

ok 10 lines

Test #27:

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

input:

4
25
23 12 23 14 10 19 17 2 25 18 11 7 10 7 10 7 10 7 1 10 7 10 7 10 7
25
6 10 3 22 18 23 11 2 8 10 15 3 14 10 14 10 14 10 1 14 10 14 10 14 10
25
7 13 3 16 14 6 4 16 21 8 5 20 17 1 17 1 17 1 2 17 1 17 1 17 1
25
11 8 3 8 21 20 1 2 17 15 17 3 7 21 7 21 7 21 1 7 21 7 21 7 21

output:

19
19
20
19

result:

ok 4 lines

Test #28:

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

input:

1
99
87 35 81 77 78 24 83 46 65 1 27 46 40 91 90 47 43 52 15 73 22 92 99 11 10 76 65 39 20 93 44 57 87 71 96 33 1 40 30 64 61 60 33 31 43 62 78 59 68 90 81 78 81 78 81 78 81 78 81 78 81 78 81 78 81 78 81 78 81 78 81 78 81 78 1 81 78 81 78 81 78 81 78 81 78 81 78 81 78 81 78 81 78 81 78 81 78 81 78

output:

83

result:

ok single line: '83'

Test #29:

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

input:

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

output:

5
6
2
2
2
5
7
2
3
1

result:

ok 10 lines

Test #30:

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

input:

5
20
19 20 4 20 4 20 4 20 8 20 8 20 4 8 20 4 20 8 20 8
20
10 14 6 14 6 14 6 4 14 6 14 6 14 6 4 14 6 14 6 14
20
17 12 2 12 2 12 2 12 2 12 2 12 2 12 2 12 2 18 12 18
20
6 4 2 20 4 2 4 2 4 2 20 4 20 4 20 4 2 4 2 20
20
7 14 20 14 20 14 20 14 20 14 20 14 16 14 20 14 20 14 20 16

output:

11
12
4
13
3

result:

ok 5 lines

Test #31:

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

input:

2
49
30 13 26 13 26 13 26 13 26 13 26 23 13 26 23 13 26 13 26 13 26 13 26 13 26 13 26 13 26 13 26 13 26 23 13 26 13 26 13 26 13 26 13 26 23 13 26 13 23
50
36 21 9 21 9 21 48 21 9 21 9 21 9 21 48 21 9 21 9 21 9 48 21 9 21 9 21 9 21 9 21 9 21 9 48 21 9 21 9 21 9 21 9 48 21 48 21 9 21 9

output:

24
32

result:

ok 2 lines

Test #32:

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

input:

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

output:

4
6
4
3
5
3
6
7
1

result:

ok 9 lines

Test #33:

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

input:

4
24
21 17 10 7 17 10 17 10 17 10 17 10 17 10 17 10 17 10 17 10 17 10 7 17
25
13 12 19 12 19 12 19 12 19 16 12 19 12 19 12 19 16 12 19 16 12 19 12 19 16
25
18 21 24 21 24 21 24 23 21 24 21 24 21 24 21 24 21 24 21 24 23 21 24 23 21
25
13 2 6 2 6 2 6 2 16 2 6 2 6 2 6 2 6 2 6 2 6 2 16 2 16

output:

7
19
16
4

result:

ok 4 lines

Test #34:

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

input:

1
100
46 97 37 97 37 97 37 97 37 97 37 97 37 97 37 97 37 97 37 97 37 97 38 97 37 97 37 97 37 97 37 97 37 38 97 37 97 37 97 37 97 37 97 37 97 37 97 37 97 37 97 38 97 37 97 37 97 37 97 37 97 38 97 37 97 37 97 37 97 37 97 37 97 37 97 37 97 37 97 37 38 97 37 97 37 38 97 37 97 37 97 37 97 37 97 38 97 37 ...

output:

60

result:

ok single line: '60'

Test #35:

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

input:

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

output:

6
7
7
5
7
3
7
5
6

result:

ok 9 lines

Test #36:

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

input:

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

output:

15
18
16
16
16

result:

ok 5 lines

Test #37:

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

input:

2
49
40 39 41 17 42 30 37 24 23 43 25 18 1 40 8 29 28 5 39 44 48 12 48 37 1 40 39 41 17 42 30 37 24 23 43 25 18 1 40 8 29 28 5 39 44 48 12 48 37
50
41 27 22 34 42 11 25 30 33 31 6 34 37 40 46 15 19 36 8 4 23 39 42 14 31 1 41 27 22 34 42 11 25 30 33 31 6 34 37 40 46 15 19 36 8 4 23 39 42 14

output:

45
42

result:

ok 2 lines

Test #38:

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

input:

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

output:

6
4
6
5
5
5
6
6
3
6

result:

ok 10 lines

Test #39:

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

input:

4
24
3 8 2 22 17 4 5 1 18 8 1 10 1 3 8 2 22 17 4 5 1 18 8 1
25
11 12 3 20 5 20 4 9 3 15 21 20 1 11 12 3 20 5 20 4 9 3 15 21 20
25
14 13 21 12 18 25 15 18 10 19 6 25 1 14 13 21 12 18 25 15 18 10 19 6 25
25
15 20 22 3 18 13 3 24 25 16 23 20 1 15 20 22 3 18 13 3 24 25 16 23 20

output:

20
21
22
21

result:

ok 4 lines

Test #40:

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

input:

1
100
22 35 21 19 100 1 31 65 67 3 92 84 29 7 67 44 22 56 81 94 6 17 52 84 38 51 86 29 93 35 48 3 77 29 53 11 27 16 30 27 75 59 67 48 79 55 92 47 78 64 1 22 35 21 19 100 1 31 65 67 3 92 84 29 7 67 44 22 56 81 94 6 17 52 84 38 51 86 29 93 35 48 3 77 29 53 11 27 16 30 27 75 59 67 48 79 55 92 47 78

output:

94

result:

ok single line: '94'

Test #41:

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

input:

47
2
1 2
2
2 1
2
1 2
2
2 1
2
2 1
2
2 1
2
1 2
2
1 2
2
1 2
2
2 1
2
2 1
2
1 2
2
2 1
2
2 1
2
1 2
2
1 2
2
1 2
2
1 2
2
2 1
2
1 2
2
2 1
2
1 2
2
2 1
2
2 1
2
1 2
2
1 2
2
1 2
2
1 2
2
2 1
2
2 1
2
2 1
2
1 2
2
1 2
2
1 2
2
2 1
2
1 2
2
2 1
2
1 2
2
2 1
2
2 1
2
1 2
3
2 1 2
3
1 3 2
3
3 2 1
3
2 3 2
3
1 3 1
3
2 3 1

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
1

result:

ok 47 lines

Test #42:

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

input:

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

output:

5
6
7
7
6
7
7
5
6
7

result:

ok 10 lines

Test #43:

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

input:

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

output:

15
16
16
14
16

result:

ok 5 lines

Test #44:

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

input:

2
49
2 28 46 41 17 13 1 37 14 22 30 7 46 16 25 47 41 10 46 42 13 7 12 16 29 44 22 37 26 18 36 22 49 25 49 20 45 35 10 4 31 5 4 46 13 27 7 44 16
50
1 6 36 18 43 18 12 2 37 6 25 18 25 6 37 47 2 36 39 24 9 13 7 37 28 29 3 38 11 3 1 42 20 37 10 46 2 29 46 39 33 7 13 23 6 15 31 38 33 9

output:

44
45

result:

ok 2 lines

Test #45:

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

input:

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

output:

7
7
6
7
8
6
8
7
8

result:

ok 9 lines

Test #46:

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

input:

4
24
14 9 10 6 17 4 15 20 5 3 9 3 4 12 16 24 2 12 9 8 7 15 4 20
25
17 23 17 10 16 11 6 20 8 11 14 20 18 23 6 16 10 24 8 18 13 18 10 9 25
25
22 18 15 17 13 10 20 10 13 14 6 21 22 24 14 10 24 11 15 2 24 10 20 8 6
25
4 25 3 24 5 20 14 2 7 6 25 12 25 15 12 14 6 17 2 9 21 15 21 6 5

output:

20
21
19
21

result:

ok 4 lines

Test #47:

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

input:

1
100
60 82 67 52 80 4 67 13 57 75 99 22 82 88 30 22 14 8 100 98 95 81 52 83 43 87 59 37 48 64 35 21 90 93 74 53 92 97 63 18 16 68 62 73 56 49 89 41 27 55 73 65 97 75 17 16 78 94 93 77 20 85 98 16 88 24 84 20 93 44 2 24 29 66 48 88 65 77 14 80 20 17 90 8 33 64 10 2 98 50 29 28 44 87 74 50 20 25 72 75

output:

94

result:

ok single line: '94'

Subtask #2:

score: 10
Accepted

Dependency #1:

100%
Accepted

Test #48:

score: 10
Accepted
time: 6ms
memory: 8052kb

input:

48
10
3 4 6 9 1 8 5 2 10 7
10
2 6 1 5 10 8 4 9 3 7
10
6 2 3 8 10 5 1 9 7 4
10
7 2 3 9 6 4 5 8 1 10
10
10 4 7 8 3 2 5 6 1 9
10
5 7 1 8 3 10 4 2 6 9
10
1 10 7 5 4 3 2 6 9 8
10
7 9 3 10 1 5 8 6 4 2
10
6 5 1 2 9 7 10 4 3 8
10
4 8 7 9 1 6 3 10 2 5
10
6 8 9 4 7 1 10 3 2 5
10
9 1 7 2 5 3 4 8 10 6
10
2 9 5 ...

output:

8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9

result:

ok 48 lines

Test #49:

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

input:

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

output:

18
18
18
18
18
18
18
18
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19

result:

ok 24 lines

Test #50:

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

input:

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

output:

53
53
53
53
53
53
54
54
54

result:

ok 9 lines

Test #51:

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

input:

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

output:

20
20
20
20
20
20
20
20
20
20
21
21
21
21
21
21
21
21
21
21
21
21

result:

ok 22 lines

Test #52:

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

input:

4
125
92 50 77 114 83 35 52 107 79 57 117 75 58 111 99 81 6 42 25 26 53 73 30 1 98 49 89 121 27 65 116 5 3 66 88 123 101 120 110 108 76 106 22 85 63 119 10 8 104 94 70 21 90 16 23 33 125 36 96 67 69 15 32 68 51 112 118 102 64 54 2 19 20 109 43 17 14 82 7 91 95 55 37 11 47 93 31 34 46 78 39 74 13 71 ...

output:

123
123
123
123

result:

ok 4 lines

Test #53:

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

input:

1
500
485 346 384 234 289 165 24 368 198 22 401 338 404 488 81 437 60 186 459 104 287 407 55 380 473 321 184 82 315 357 76 215 116 364 396 237 268 441 415 196 310 59 176 53 223 224 134 143 333 182 390 66 273 151 288 395 468 344 434 285 242 385 49 430 175 327 114 336 46 102 461 113 325 163 119 456 32...

output:

498

result:

ok single line: '498'

Test #54:

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

input:

50
9
4 7 5 6 5 6 7 1 4
9
1 3 4 3 1 5 4 5 8
10
8 9 5 10 4 5 7 6 8 10
10
1 6 10 6 1 6 1 6 1 10
10
2 4 10 2 4 2 4 10 2 4
10
1 8 6 8 4 7 6 7 6 7
10
1 4 7 5 4 7 1 7 1 5
10
8 7 1 4 10 8 4 3 7 3
10
5 10 3 5 10 3 2 3 10 2
10
1 10 7 10 3 1 3 1 5 10
10
9 8 4 8 5 6 5 6 5 2
10
4 8 4 7 6 8 7 9 5 4
10
4 2 6 2 8 6...

output:

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

result:

ok 50 lines

Test #55:

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

input:

24
20
20 17 2 16 18 12 3 2 15 5 1 8 2 19 18 8 3 16 1 14
20
11 8 2 9 8 2 20 3 9 14 19 9 2 18 11 8 14 8 18 3
20
3 20 10 12 5 7 5 12 4 12 7 4 8 11 8 2 7 11 8 11
20
7 4 8 15 8 15 4 3 4 5 19 5 19 7 17 3 17 8 12 3
20
4 12 17 15 4 15 4 15 5 12 5 4 5 17 12 4 15 4 15 17
20
19 20 12 16 11 15 19 13 11 17 12 7 ...

output:

16
15
14
15
14
17
14
10
15
14
17
16
15
15
11
15
14
15
12
12
14
15
12
16

result:

ok 24 lines

Test #56:

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

input:

10
49
34 9 24 9 24 9 2 16 2 16 2 48 11 36 11 29 28 29 28 29 10 33 10 29 41 29 41 44 18 44 18 46 36 16 36 34 26 29 44 39 5 18 34 1 34 47 3 18 1
50
33 27 20 39 29 1 39 45 1 23 14 21 23 35 22 13 41 13 20 14 22 47 50 22 25 37 27 22 20 47 20 29 36 20 14 28 8 47 22 30 44 36 43 25 50 10 36 43 25 11
50
23 3...

output:

40
43
41
39
44
44
39
38
45
41

result:

ok 10 lines

Test #57:

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

input:

21
23
16 10 20 17 11 15 12 20 12 20 11 20 11 15 1 15 17 16 10 12 16 17 15
23
22 18 19 18 6 19 6 20 5 17 15 17 1 8 1 15 16 10 23 20 5 16 11
23
18 8 3 20 6 20 4 1 14 3 19 23 7 13 5 6 3 17 8 19 18 1 13
23
8 15 22 15 22 7 9 7 9 17 7 17 23 8 23 8 10 2 18 7 18 7 8
23
3 11 6 5 13 12 4 12 11 2 16 3 7 1 6 14...

output:

17
19
19
17
18
13
16
14
16
18
20
15
20
17
19
19
18
18
17
17
20

result:

ok 21 lines

Test #58:

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

input:

4
124
98 26 30 26 30 40 30 7 108 7 108 40 59 40 51 123 106 123 106 123 106 7 26 7 26 82 26 51 95 51 26 59 26 98 51 98 123 26 106 98 106 98 26 30 26 30 26 80 26 80 26 13 110 13 110 13 123 51 40 26 40 26 40 26 80 26 80 59 80 59 80 59 13 98 13 98 13 98 74 106 82 106 82 80 108 80 121 7 26 30 26 30 26 30...

output:

104
109
111
111

result:

ok 4 lines

Test #59:

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

input:

1
496
4 371 455 3 430 3 430 3 430 3 430 3 430 3 430 3 430 3 430 3 430 326 162 326 162 326 162 326 162 326 162 326 32 487 32 487 32 487 32 487 32 487 32 487 32 487 32 487 32 487 32 487 32 160 163 160 163 160 163 319 131 319 131 319 131 319 131 319 131 319 131 319 45 386 45 386 45 386 45 386 45 386 45...

output:

464

result:

ok single line: '464'

Test #60:

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

input:

49
10
3 5 3 5 3 5 6 3 5 2
10
8 7 8 7 8 7 5 8 7 3
10
3 7 3 7 3 7 2 3 7 8
10
3 1 3 1 3 1 6 3 1 4
10
5 2 5 2 5 2 10 5 2 6
10
2 5 2 5 2 5 8 2 5 7
10
4 1 4 1 4 1 2 4 1 10
10
10 1 10 1 10 1 9 10 1 6
10
10 3 10 3 10 3 5 10 3 6
10
1 7 1 7 1 7 2 1 7 5
10
1 3 1 3 1 3 5 1 3 6
10
10 4 10 4 10 4 7 10 4 2
10
9 5 ...

output:

5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
6
6
6
6
6
6

result:

ok 49 lines

Test #61:

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

input:

25
19
17 16 17 16 17 16 18 17 16 15 12 15 12 14 15 12 8 7 13
19
15 9 15 9 15 9 3 15 9 4 2 4 2 18 4 2 10 16 5
19
3 18 3 18 3 18 8 3 18 10 15 10 15 7 10 15 1 16 13
19
4 6 4 6 4 6 18 4 6 7 16 7 16 9 7 16 15 14 8
20
15 20 15 20 15 20 10 15 20 16 17 16 17 5 16 17 2 18 6 12
20
7 18 7 18 7 18 6 7 18 4 8 4 ...

output:

14
14
14
14
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15

result:

ok 25 lines

Test #62:

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

input:

9
55
10 45 10 45 10 45 36 10 45 40 6 40 6 13 40 6 29 12 29 12 47 29 12 44 16 44 16 35 44 16 41 27 41 27 32 41 27 37 1 37 1 54 37 1 38 51 38 51 7 38 51 46 19 53 42
55
23 22 23 22 23 22 18 23 22 39 14 39 14 4 39 14 45 26 45 26 6 45 26 52 15 52 15 31 52 15 55 40 55 40 24 55 40 25 27 25 27 46 25 27 50 1...

output:

50
50
50
50
50
51
51
51
51

result:

ok 9 lines

Test #63:

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

input:

21
23
15 3 15 3 15 3 20 15 3 14 12 14 12 11 14 12 16 17 16 17 23 16 17
23
14 2 14 2 14 2 7 14 2 11 19 11 19 4 11 19 16 15 16 15 17 16 15
23
1 17 1 17 1 17 11 1 17 14 15 14 15 12 14 15 19 16 19 16 5 19 16
23
12 8 12 8 12 8 10 12 8 6 21 6 21 14 6 21 16 7 16 7 9 16 7
23
23 17 23 17 23 17 16 23 17 19 13...

output:

18
18
18
18
18
18
18
18
19
19
19
19
19
19
19
19
19
19
19
19
19

result:

ok 21 lines

Test #64:

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

input:

4
123
98 43 98 43 98 43 89 98 43 8 27 8 27 82 8 27 81 69 81 69 118 81 69 88 73 88 73 6 88 73 116 65 116 65 52 116 65 32 102 32 102 96 32 102 101 23 101 23 1 101 23 4 46 4 46 36 4 46 10 26 10 26 72 10 26 35 84 35 84 9 35 84 66 39 66 39 25 66 39 79 90 79 90 28 79 90 99 31 99 31 106 99 31 97 109 97 109...

output:

118
119
119
119

result:

ok 4 lines

Test #65:

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

input:

1
496
466 249 466 249 466 249 331 466 249 382 121 382 121 338 382 121 188 22 188 22 253 188 22 201 11 201 11 429 201 11 181 5 181 5 277 181 5 272 303 272 303 493 272 303 403 375 403 375 196 403 375 16 107 16 107 119 16 107 478 340 478 340 263 478 340 402 144 402 144 252 402 144 231 463 231 463 496 2...

output:

491

result:

ok single line: '491'

Test #66:

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

input:

46
10
1 7 4 8 7 9 3 1 9 3
10
1 9 4 2 5 7 10 1 7 10
10
5 9 10 9 10 5 10 1 5 10
10
3 4 3 2 7 3 1 2 3 1
10
7 9 10 5 8 6 8 1 6 8
10
10 6 9 3 7 1 7 2 1 7
10
3 2 3 10 5 6 4 1 6 4
11
2 10 9 11 6 4 2 5 1 2 5
11
2 5 10 4 5 11 6 1 2 6 1
11
4 9 11 10 5 1 11 10 1 11 10
11
5 8 6 9 11 7 2 11 1 2 11
11
8 4 3 5 8 1...

output:

8
8
5
5
7
7
7
8
8
8
8
8
8
8
8
7
8
8
7
8
8
8
8
8
8
8
8
7
8
9
8
7
7
8
8
7
8
8
9
7
8
7
7
8
8
9

result:

ok 46 lines

Test #67:

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

input:

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

output:

14
16
15
16
17
16
17
17
16
17
17
17
17
15
17
17
17
17
17
18
17
17
16
15

result:

ok 24 lines

Test #68:

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

input:

10
49
41 22 48 29 27 41 43 36 23 11 16 23 13 43 17 45 11 41 49 20 12 14 5 43 1 12 1 12 1 12 1 12 1 12 1 12 2 1 12 1 12 1 12 1 12 1 12 1 12
49
21 24 9 47 30 25 1 22 23 10 21 44 1 8 33 2 24 5 22 40 20 4 26 41 5 36 5 36 5 36 5 36 5 36 5 36 1 5 36 5 36 5 36 5 36 5 36 5 36
49
46 41 30 8 47 26 29 40 28 29...

output:

40
39
39
41
42
40
40
41
43
41

result:

ok 10 lines

Test #69:

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

input:

20
24
7 16 20 14 13 14 1 17 2 3 11 13 12 13 12 13 12 1 13 12 13 12 13 12
24
24 1 22 6 14 23 1 18 20 18 3 9 4 9 4 9 4 1 9 4 9 4 9 4
25
9 24 13 23 16 6 5 11 18 22 7 6 4 16 4 16 4 16 1 4 16 4 16 4 16
25
15 5 6 9 11 16 6 2 12 11 21 18 1 7 1 7 1 7 2 1 7 1 7 1 7
25
12 20 23 1 12 14 2 14 6 24 22 7 15 1 15 ...

output:

18
19
19
20
19
20
19
19
19
19
20
19
17
20
20
19
20
21
19
20

result:

ok 20 lines

Test #70:

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

input:

4
124
67 44 82 108 18 79 124 18 118 85 68 80 43 42 52 15 97 46 123 93 9 92 38 89 64 16 75 39 62 43 26 62 9 121 2 52 84 116 35 122 14 1 21 76 100 99 30 58 116 67 49 47 17 11 4 49 112 76 57 56 79 68 70 121 44 121 44 121 44 121 44 121 44 121 44 121 44 121 44 121 44 121 44 121 44 121 44 121 44 121 44 12...

output:

106
107
106
108

result:

ok 4 lines

Test #71:

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

input:

1
498
104 289 280 232 207 204 107 209 281 159 190 398 264 156 295 34 87 231 274 295 93 397 462 27 84 374 149 262 126 324 224 342 212 170 458 166 21 253 66 363 402 276 5 463 452 399 108 30 81 74 349 354 155 173 428 379 160 153 51 141 100 115 40 361 179 304 52 25 112 150 42 414 207 209 428 34 475 24 6...

output:

433

result:

ok single line: '433'

Test #72:

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

input:

47
10
2 9 8 9 8 9 5 9 8 5
10
2 9 8 9 8 9 8 9 5 9
10
7 5 10 5 10 9 5 9 5 9
10
7 10 8 10 8 10 8 10 8 9
10
6 5 7 5 7 5 7 5 7 3
10
7 3 4 3 4 3 4 3 4 2
10
3 9 6 9 6 9 6 9 6 9
10
2 8 9 3 8 9 3 8 9 8
10
9 8 5 8 5 8 5 8 10 8
10
2 7 3 7 3 7 3 7 3 7
10
6 2 5 2 5 2 5 4 2 5
10
2 7 8 7 8 7 8 7 8 9
10
3 9 2 9 5 9...

output:

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

result:

ok 47 lines

Test #73:

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

input:

24
20
9 12 10 12 10 12 10 12 10 12 10 12 10 12 10 12 10 1 12 10
20
9 4 20 4 20 4 20 4 20 4 20 4 18 4 20 4 20 4 20 18
20
17 20 4 10 20 4 20 4 20 4 20 4 20 4 20 10 20 4 20 4
20
7 20 18 20 18 20 18 20 18 20 18 20 18 20 18 10 20 18 10 20
20
1 8 3 8 3 8 3 12 8 3 8 3 8 12 8 3 8 3 12 8
20
12 6 13 6 9 6 9 6...

output:

5
3
6
6
14
4
3
2
12
15
9
5
2
2
10
3
3
6
10
7
2
2
14
15

result:

ok 24 lines

Test #74:

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

input:

9
55
39 51 35 51 35 51 35 51 35 51 35 51 3 51 3 51 35 51 35 51 35 51 35 51 35 51 35 51 35 51 3 51 35 51 35 51 35 51 35 51 35 51 35 51 35 51 35 51 3 51 35 51 35 51 3
55
44 2 40 2 40 2 40 2 28 2 40 2 40 2 40 28 2 40 2 40 2 40 2 40 2 40 2 40 2 40 2 40 2 28 2 40 2 28 2 40 2 40 2 40 2 40 2 28 2 40 2 28 2...

output:

6
26
36
31
8
37
36
8
16

result:

ok 9 lines

Test #75:

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

input:

20
24
2 8 14 8 14 8 14 8 14 8 14 8 1 8 14 1 8 14 8 1 8 14 8 1
25
1 8 5 8 5 8 5 8 5 8 5 8 5 8 5 8 5 19 8 5 8 5 8 19 8
25
7 25 17 25 17 25 17 25 17 25 17 25 17 25 17 25 6 25 17 6 25 17 25 17 6
25
13 20 3 20 11 20 3 20 3 20 3 11 20 3 20 3 20 3 20 3 20 3 20 3 20
25
6 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 10...

output:

13
11
10
16
4
8
7
18
4
4
3
8
15
11
8
10
18
3
4
11

result:

ok 20 lines

Test #76:

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

input:

4
124
41 58 95 58 95 58 95 58 95 58 95 58 100 58 95 58 95 58 95 58 95 100 58 95 58 95 58 95 58 95 58 95 58 95 58 95 58 95 100 58 95 58 95 58 100 58 95 58 95 58 95 58 95 58 95 58 95 58 95 58 100 58 95 58 95 58 95 58 95 58 95 58 95 100 58 95 58 95 100 58 95 58 95 58 95 58 95 58 95 58 95 58 95 100 58 9...

output:

50
16
90
66

result:

ok 4 lines

Test #77:

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

input:

1
498
246 440 479 440 479 440 479 440 479 440 479 440 479 440 479 440 479 420 440 479 440 479 440 479 440 479 440 479 440 479 420 440 479 440 479 440 479 440 479 440 479 440 479 440 479 440 479 440 479 420 440 479 440 479 440 479 420 440 479 440 479 440 479 440 479 440 479 440 479 440 479 440 479 44...

output:

361

result:

ok single line: '361'

Test #78:

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

input:

47
10
10 2 5 4 7 1 10 2 5 4
10
10 2 10 5 3 1 10 2 10 5
10
2 7 10 9 8 1 2 7 10 9
10
9 10 2 6 4 1 9 10 2 6
10
6 3 10 4 3 1 6 3 10 4
10
5 4 5 4 8 1 5 4 5 4
10
5 7 5 8 2 1 5 7 5 8
10
8 1 9 3 10 1 8 1 9 3
10
8 5 6 9 4 1 8 5 6 9
10
10 5 2 6 8 1 10 5 2 6
10
1 2 10 2 6 2 1 2 10 2
10
1 5 8 3 2 3 1 5 8 3
10
7...

output:

6
4
6
6
6
2
4
5
6
6
3
5
6
5
6
6
6
5
4
6
6
6
6
7
7
7
6
7
7
4
5
7
7
7
7
7
3
7
7
7
7
4
7
7
7
7
4

result:

ok 47 lines

Test #79:

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

input:

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

output:

18
15
15
16
17
17
16
17
18
18
17
17
18
17
18
17
18
17
18
18
18
17
17
17

result:

ok 24 lines

Test #80:

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

input:

10
50
11 31 46 3 1 39 5 17 21 31 10 36 20 2 43 29 38 8 21 26 30 26 46 42 19 1 11 31 46 3 1 39 5 17 21 31 10 36 20 2 43 29 38 8 21 26 30 26 46 42
50
10 24 48 46 4 45 17 24 41 47 25 4 13 38 42 46 47 19 30 18 8 4 19 17 29 1 10 24 48 46 4 45 17 24 41 47 25 4 13 38 42 46 47 19 30 18 8 4 19 17
50
37 29 21...

output:

42
44
43
40
40
43
42
44
42
45

result:

ok 10 lines

Test #81:

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

input:

21
23
20 15 7 1 14 19 1 11 22 19 7 1 20 15 7 1 14 19 1 11 22 19 7
23
15 1 2 19 10 13 15 11 9 4 7 1 15 1 2 19 10 13 15 11 9 4 7
23
15 18 12 14 22 9 14 6 16 5 15 1 15 18 12 14 22 9 14 6 16 5 15
23
19 22 17 11 14 21 9 1 15 8 18 1 19 22 17 11 14 21 9 1 15 8 18
23
9 12 3 14 20 3 19 4 22 1 22 1 9 12 3 14 ...

output:

15
16
17
18
16
19
17
17
20
19
20
20
21
21
20
20
21
21
21
20
20

result:

ok 21 lines

Test #82:

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

input:

4
124
80 98 31 65 9 54 50 51 75 26 88 53 46 66 61 59 42 117 72 122 101 34 104 11 29 54 55 118 40 119 47 76 113 49 20 23 56 88 44 45 33 63 82 37 54 85 14 41 116 89 71 97 112 116 80 71 96 82 93 108 105 124 1 80 98 31 65 9 54 50 51 75 26 88 53 46 66 61 59 42 117 72 122 101 34 104 11 29 54 55 118 40 119...

output:

119
119
120
119

result:

ok 4 lines

Test #83:

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

input:

1
496
460 199 180 388 477 220 495 339 84 65 382 120 127 34 258 407 390 463 452 357 459 242 438 256 456 55 488 223 389 297 198 85 396 475 275 242 194 109 321 288 430 363 284 316 75 295 421 287 112 204 76 438 418 3 355 6 470 373 421 274 252 387 478 297 451 443 324 6 192 331 115 142 207 251 144 373 109...

output:

488

result:

ok single line: '488'

Test #84:

score: 0
Accepted
time: 22ms
memory: 8164kb

input:

233
2
1 2
2
2 1
2
2 1
2
1 2
2
2 1
2
1 2
2
2 1
2
1 2
2
2 1
2
2 1
2
2 1
2
1 2
2
1 2
2
2 1
2
2 1
2
1 2
2
2 1
2
2 1
2
2 1
2
2 1
2
2 1
2
2 1
2
1 2
2
2 1
2
2 1
2
1 2
2
2 1
2
2 1
2
1 2
2
1 2
2
1 2
2
1 2
2
2 1
2
2 1
2
2 1
2
1 2
2
2 1
2
1 2
2
1 2
2
1 2
2
2 1
2
2 1
2
1 2
2
1 2
2
1 2
2
2 1
2
1 2
2
1 2
2
2 1
2
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 233 lines

Test #85:

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

input:

48
10
8 1 5 1 7 6 2 5 9 10
10
10 1 8 7 8 2 1 10 4 9
10
2 7 8 4 6 9 1 7 9 7
10
1 6 5 10 7 1 8 10 7 6
10
7 6 2 4 2 10 9 10 6 1
10
7 3 7 8 7 6 5 8 3 9
10
1 8 5 4 6 7 8 10 9 2
10
7 8 4 6 1 7 1 3 1 6
10
4 7 8 7 8 9 5 3 1 7
10
1 2 10 4 6 5 2 1 10 2
10
6 8 2 1 10 6 2 6 9 3
10
10 6 7 1 3 1 3 9 6 7
10
3 1 8 ...

output:

7
7
6
6
6
5
8
5
5
6
6
6
8
6
7
8
6
6
6
7
7
6
7
5
6
7
4
6
6
8
8
8
7
7
7
8
7
7
7
8
7
7
6
8
8
6
7
6

result:

ok 48 lines

Test #86:

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

input:

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

output:

14
15
16
16
16
16
16
17
15
16
16
16
15
16
15
15
16
15
16
16
16
14
15
16
16

result:

ok 25 lines

Test #87:

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

input:

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

output:

43
44
44
46
44
45
44
43
44
46

result:

ok 10 lines

Test #88:

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

input:

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

output:

20
20
21
20
20
20
20
21
19
20
21
21
22
22
20
21
20
20
21
20

result:

ok 20 lines

Test #89:

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

input:

4
124
98 92 44 40 110 41 40 37 51 18 54 61 73 77 30 45 37 122 29 65 4 108 86 84 11 106 61 78 67 19 58 81 106 123 124 7 83 30 97 58 86 81 77 124 102 96 58 98 92 40 59 82 34 11 95 55 98 1 58 62 117 63 105 33 61 25 28 14 120 89 103 65 84 107 40 51 72 17 39 64 47 113 68 52 116 98 73 4 93 110 113 30 18 2...

output:

118
119
118
119

result:

ok 4 lines

Test #90:

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

input:

1
495
301 485 208 223 357 107 240 431 453 493 289 275 292 209 161 333 100 277 348 89 215 399 45 380 226 252 17 150 437 70 106 246 322 149 235 354 64 270 356 264 493 39 472 76 345 191 86 392 213 313 316 486 107 43 171 89 340 364 482 443 316 215 122 206 222 326 54 222 41 405 284 405 407 490 269 407 14...

output:

487

result:

ok single line: '487'

Subtask #3:

score: 25
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #91:

score: 25
Accepted
time: 44ms
memory: 7632kb

input:

396
10
1 7 2 4 9 3 10 5 8 6
10
9 3 8 6 1 10 7 2 4 5
10
3 10 6 9 1 5 7 2 8 4
10
4 9 2 7 5 6 10 3 1 8
10
7 4 1 8 5 3 9 2 6 10
10
1 7 9 5 4 2 8 10 6 3
10
7 1 9 4 5 6 8 3 2 10
10
3 10 9 2 4 5 8 1 7 6
10
5 2 10 8 7 9 4 1 3 6
10
8 7 3 4 6 5 9 1 2 10
10
9 7 1 2 4 5 6 10 3 8
10
2 5 10 9 8 1 3 6 4 7
10
5 4 7...

output:

8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
...

result:

ok 396 lines

Test #92:

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

input:

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

output:

18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
...

result:

ok 193 lines

Test #93:

score: 0
Accepted
time: 10ms
memory: 7564kb

input:

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

output:

49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
49
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50

result:

ok 77 lines

Test #94:

score: 0
Accepted
time: 9ms
memory: 8356kb

input:

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

output:

60
60
60
60
60
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61
61

result:

ok 63 lines

Test #95:

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

input:

4
993
63 51 630 796 579 766 924 679 394 261 908 486 543 273 382 619 42 613 260 629 39 246 293 109 611 447 501 149 374 362 717 769 612 953 983 413 638 721 772 95 948 286 667 877 355 889 989 236 674 921 351 361 530 691 910 777 724 11 727 369 941 562 148 733 898 435 649 956 173 848 806 504 488 553 44 2...

output:

991
991
992
992

result:

ok 4 lines

Test #96:

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

input:

1
3969
1728 1713 701 3683 336 2736 1097 3094 1082 1893 2130 3909 977 2998 1442 407 2358 607 1556 3052 3371 2226 3917 3246 3454 1415 583 3650 2513 3027 3318 2470 289 2425 1423 16 3956 497 278 1513 3405 2087 1858 2315 3329 3374 1685 610 3912 1343 3175 2936 1387 3597 1391 642 3273 1895 2217 2737 3926 1...

output:

3967

result:

ok single line: '3967'

Test #97:

score: 0
Accepted
time: 37ms
memory: 7672kb

input:

367
10
5 1 5 6 10 5 7 10 1 10
10
8 5 8 5 4 10 4 5 10 5
10
9 4 7 4 10 4 10 4 7 10
10
10 4 10 4 5 10 1 3 10 5
10
6 9 2 4 8 6 9 3 5 8
10
9 8 10 5 10 7 10 7 10 5
10
4 5 7 9 4 7 4 7 4 9
10
7 4 3 4 3 8 3 4 3 1
10
3 5 4 3 8 3 8 7 8 7
10
9 6 3 6 9 3 9 3 6 9
10
10 7 10 7 10 1 10 1 10 1
10
2 8 7 1 7 1 4 2 8 1...

output:

7
4
4
5
8
4
4
3
5
5
2
5
4
4
2
4
4
5
6
6
7
7
4
7
5
4
5
3
6
6
6
6
6
5
6
5
5
6
7
4
6
6
4
6
6
3
7
3
6
6
6
7
5
5
5
6
7
7
5
6
6
5
5
4
4
3
6
8
5
7
5
6
8
3
8
5
6
5
7
4
5
4
6
7
5
4
7
6
6
6
4
7
7
6
7
6
6
6
6
7
6
7
6
5
6
6
6
4
5
6
3
5
5
2
6
7
4
8
7
4
5
3
7
7
7
6
5
7
7
8
6
7
5
7
3
7
4
5
3
7
7
8
5
6
9
7
3
7
6
3
...

result:

ok 367 lines

Test #98:

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

input:

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

output:

15
15
14
15
12
14
15
14
12
10
14
15
11
14
13
10
14
15
10
15
14
12
14
15
12
16
13
14
10
16
16
15
14
14
12
12
13
13
12
13
15
14
15
16
11
16
14
16
15
13
11
15
13
15
7
15
15
16
14
14
16
13
13
11
15
12
12
13
13
13
16
14
13
13
12
12
11
16
14
16
14
13
12
11
13
12
11
13
16
13
15
16
13
15
15
17
13
15
14
15
1...

result:

ok 200 lines

Test #99:

score: 0
Accepted
time: 10ms
memory: 8008kb

input:

73
54
29 8 54 35 46 44 38 13 19 14 52 11 16 8 39 45 54 26 25 31 54 24 26 47 54 10 33 19 14 15 46 25 8 38 16 50 16 33 39 30 38 27 49 35 47 5 44 5 13 10 3 49 21 9
54
8 41 34 15 8 41 26 8 3 8 3 13 17 13 17 6 27 6 50 41 50 41 46 17 27 46 3 15 3 15 13 15 17 46 15 46 15 46 26 41 4 27 33 4 33 4 27 15 27 41...

output:

48
42
49
49
48
42
47
47
49
48
42
49
49
46
46
47
48
49
44
48
44
41
44
46
40
45
47
47
44
48
47
45
48
42
45
48
41
49
49
50
47
49
48
48
46
44
45
47
46
46
48
42
49
49
45
47
45
46
50
48
46
45
45
47
51
45
50
47
48
47
50
49
46

result:

ok 73 lines

Test #100:

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

input:

60
66
34 49 15 40 23 63 34 11 34 11 32 21 32 21 60 56 60 65 28 65 45 32 45 62 46 65 46 25 13 62 10 62 31 56 31 28 57 42 44 42 44 13 21 56 40 59 43 27 33 8 26 8 26 21 23 16 56 16 56 18 41 60 41 19 3 32
66
32 44 21 46 26 43 27 66 10 38 59 13 16 3 12 45 47 50 35 2 61 26 19 38 59 41 61 39 49 41 50 18 61...

output:

60
59
51
59
55
57
60
57
56
61
54
58
45
61
59
57
59
59
58
58
58
59
57
57
53
59
55
56
53
58
55
52
52
58
57
55
53
55
59
57
52
58
60
58
58
54
60
59
59
59
60
60
58
56
59
60
61
50
61
60

result:

ok 60 lines

Test #101:

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

input:

4
997
658 307 995 307 995 307 995 307 995 307 995 307 995 632 955 632 955 632 955 632 955 632 955 632 955 632 955 632 955 287 736 287 736 287 736 287 736 287 736 287 736 287 736 494 736 494 736 703 210 703 210 703 210 703 210 703 210 703 210 243 435 200 382 200 382 200 382 200 382 200 382 200 382 20...

output:

968
940
903
956

result:

ok 4 lines

Test #102:

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

input:

1
3969
1879 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 2981 2246 298...

output:

3720

result:

ok single line: '3720'

Test #103:

score: 0
Accepted
time: 42ms
memory: 8016kb

input:

365
10
10 8 10 8 10 8 5 10 8 3
10
2 6 2 6 2 6 3 2 6 7
10
3 7 3 7 3 7 8 3 7 6
10
7 10 7 10 7 10 2 7 10 4
10
10 4 10 4 10 4 3 10 4 1
10
7 10 7 10 7 10 8 7 10 1
10
2 4 2 4 2 4 6 2 4 7
10
2 9 2 9 2 9 8 2 9 3
10
6 2 6 2 6 2 1 6 2 8
10
7 6 7 6 7 6 2 7 6 1
10
9 3 9 3 9 3 6 9 3 2
10
8 10 8 10 8 10 2 8 10 1
...

output:

5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
...

result:

ok 365 lines

Test #104:

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

input:

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

output:

15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
...

result:

ok 195 lines

Test #105:

score: 0
Accepted
time: 10ms
memory: 7968kb

input:

78
51
49 1 49 1 49 1 29 49 1 20 43 20 43 30 20 43 9 26 9 26 18 9 26 11 21 11 21 33 11 21 27 22 27 22 38 27 22 8 3 8 3 47 8 3 35 13 35 13 14 35 13
51
9 7 9 7 9 7 26 9 7 34 11 34 11 49 34 11 39 25 39 25 38 39 25 48 41 48 41 36 48 41 44 31 44 31 35 44 31 16 17 16 17 32 16 17 37 2 37 2 19 37 2
51
7 4 7 ...

output:

46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
46
47
47
47
47
47
47
47

result:

ok 78 lines

Test #106:

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

input:

59
67
66 49 66 49 66 49 50 66 49 62 44 62 44 2 62 44 28 18 28 18 65 28 18 11 38 11 38 51 11 38 32 1 32 1 63 32 1 42 21 42 21 54 42 21 14 53 14 53 16 14 53 9 15 9 15 5 9 15 40 30 40 30 35 40 30 31 59
67
45 54 45 54 45 54 27 45 54 9 63 9 63 59 9 63 24 12 24 12 1 24 12 66 60 66 60 47 66 60 36 46 36 46 ...

output:

62
62
62
62
62
62
62
62
62
62
62
62
62
62
62
62
62
62
62
62
62
62
62
62
62
62
63
63
63
63
63
63
63
63
63
63
63
63
63
63
63
63
63
63
63
63
63
63
63
63
63
63
63
63
63
63
63
63
63

result:

ok 59 lines

Test #107:

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

input:

4
998
378 299 378 299 378 299 295 378 299 946 16 946 16 908 946 16 750 650 750 650 525 750 650 581 463 581 463 102 581 463 38 426 38 426 116 38 426 602 215 602 215 542 602 215 119 857 119 857 84 119 857 202 356 202 356 595 202 356 610 19 610 19 50 610 19 711 591 711 591 939 711 591 439 464 439 464 8...

output:

993
993
993
993

result:

ok 4 lines

Test #108:

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

input:

1
3961
2754 3037 2754 3037 2754 3037 775 2754 3037 3197 3952 3197 3952 2080 3197 3952 3211 1453 3211 1453 452 3211 1453 1251 990 1251 990 1172 1251 990 1603 706 1603 706 3852 1603 706 2112 3835 2112 3835 2496 2112 3835 2711 2832 2711 2832 1391 2711 2832 3043 165 3043 165 633 3043 165 3377 1090 3377 ...

output:

3956

result:

ok single line: '3956'

Test #109:

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

input:

364
10
6 3 7 6 10 7 10 1 7 10
10
9 4 2 3 2 6 10 1 6 10
10
8 5 6 5 1 6 2 1 6 2
10
7 9 3 6 7 9 10 1 9 10
10
5 9 10 5 7 2 1 3 2 1
10
3 6 4 6 2 4 3 1 4 3
10
9 1 10 7 1 4 2 1 4 2
10
4 10 5 8 3 4 8 1 4 8
10
1 10 3 10 7 1 7 2 1 7
10
2 4 5 7 5 8 3 1 8 3
10
6 2 4 2 8 6 4 1 6 4
10
4 2 4 3 7 8 4 1 8 4
10
4 6 1...

output:

7
7
6
6
8
6
7
7
6
7
6
6
6
7
6
7
5
7
7
8
7
8
8
8
6
7
6
7
7
7
8
7
7
5
6
7
6
8
6
6
8
8
8
8
7
9
8
8
8
7
9
8
7
9
7
7
7
8
7
8
7
8
7
7
7
8
8
8
8
8
8
8
8
7
8
9
7
8
8
8
8
8
8
8
6
7
7
8
8
7
8
8
6
7
7
6
7
8
8
8
8
8
9
8
8
8
7
7
7
7
9
7
8
7
8
8
7
7
7
8
9
7
7
8
8
8
5
7
6
9
7
9
7
7
8
7
8
8
8
8
8
8
7
8
8
7
7
7
7
8
...

result:

ok 364 lines

Test #110:

score: 0
Accepted
time: 18ms
memory: 7732kb

input:

182
21
13 5 19 4 19 14 9 1 5 7 9 18 20 11 20 11 1 20 11 20 11
21
11 3 21 5 6 3 11 6 9 17 1 10 18 21 18 21 1 18 21 18 21
21
8 19 12 17 20 21 4 2 10 6 1 9 2 11 2 11 1 2 11 2 11
21
2 1 19 7 10 18 20 12 17 20 5 10 15 6 15 6 1 15 6 15 6
21
13 18 5 3 21 8 21 14 18 13 5 14 8 6 8 6 1 8 6 8 6
21
14 9 12 19 2...

output:

17
16
16
18
16
17
16
17
17
17
17
17
17
17
17
17
16
17
18
17
17
18
16
17
17
17
18
17
18
18
17
17
17
18
17
17
19
17
17
17
18
17
16
17
18
17
16
18
17
18
16
17
18
18
17
18
18
17
18
18
18
17
17
17
17
18
17
18
16
18
17
17
18
17
18
18
18
18
17
17
19
17
17
17
18
17
18
18
17
18
18
17
16
17
17
17
14
18
18
17
...

result:

ok 182 lines

Test #111:

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

input:

80
49
40 32 16 22 49 5 28 6 26 5 3 39 11 46 28 49 36 40 16 6 37 13 5 29 2 25 2 25 2 25 2 25 2 25 2 25 1 2 25 2 25 2 25 2 25 2 25 2 25
49
27 46 36 42 18 33 4 48 49 11 48 20 44 14 40 19 15 32 2 22 45 4 9 3 38 17 38 17 38 17 38 17 38 17 38 17 1 38 17 38 17 38 17 38 17 38 17 38 17
49
44 48 14 31 2 23 44...

output:

41
42
41
41
39
41
40
41
40
40
40
40
41
41
40
40
41
41
39
41
41
39
39
38
40
41
40
41
42
41
41
41
41
41
41
40
41
41
42
42
42
42
42
41
41
42
42
42
41
41
41
41
41
41
42
42
43
41
42
42
42
40
41
41
40
40
42
42
41
41
41
39
41
41
43
41
41
42
41
41

result:

ok 80 lines

Test #112:

score: 0
Accepted
time: 9ms
memory: 7988kb

input:

59
67
17 67 10 42 49 47 66 59 29 5 8 40 55 47 30 3 43 45 50 61 14 45 6 22 65 40 32 13 38 11 9 28 61 25 67 48 67 48 67 48 67 48 67 48 67 48 67 48 67 48 1 67 48 67 48 67 48 67 48 67 48 67 48 67 48 67 48
67
48 17 13 48 67 64 25 41 24 28 27 45 39 50 34 2 4 22 25 18 21 62 30 48 12 42 47 36 3 46 34 61 57 ...

output:

57
57
57
57
56
57
56
57
56
56
56
57
56
56
57
55
56
57
57
56
57
56
57
58
57
55
58
57
57
57
58
57
57
57
57
58
55
55
57
57
56
56
58
57
57
57
57
56
57
57
57
57
57
58
57
56
57
57
57

result:

ok 59 lines

Test #113:

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

input:

4
998
246 343 432 602 197 609 135 964 147 414 305 249 239 144 500 673 874 487 339 936 205 945 262 382 718 747 45 941 189 67 873 962 708 572 71 784 997 32 445 200 177 862 393 139 927 190 180 76 529 21 398 538 855 101 866 581 482 697 638 345 66 232 496 983 758 904 744 71 940 62 24 943 510 663 784 109 ...

output:

871
870
870
871

result:

ok 4 lines

Test #114:

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

input:

1
3968
1983 3940 2900 820 1122 3852 1108 115 587 1117 2583 3968 583 187 2085 3214 3288 2682 469 2547 1000 1337 1686 3535 2365 1377 2222 859 222 3809 2749 1542 1040 3394 3034 2638 1726 1480 160 2226 381 3818 402 1928 790 2678 3401 2280 434 47 3495 2782 2963 3358 1583 2133 1789 851 3496 1164 32 2636 3...

output:

3466

result:

ok single line: '3466'

Test #115:

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

input:

361
11
10 3 4 3 11 3 4 3 4 11 3
11
3 11 7 9 11 7 11 7 11 7 11
11
7 2 9 2 9 2 6 2 9 2 9
11
3 1 9 1 9 1 9 1 9 1 8
11
10 4 6 4 6 4 6 4 6 4 6
11
3 9 2 9 2 9 2 5 9 5 9
11
2 8 6 8 6 8 6 7 8 6 8
11
1 4 8 4 8 4 8 6 4 8 4
11
3 7 2 11 7 2 7 2 7 2 11
11
2 9 5 9 5 9 10 9 5 9 5
11
2 11 3 11 3 11 3 11 7 11 7
11
1...

output:

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

result:

ok 361 lines

Test #116:

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

input:

197
20
15 16 6 16 6 16 6 16 6 16 6 16 6 16 6 16 6 16 6 10
20
6 11 19 11 19 10 11 19 11 19 11 19 11 19 11 19 10 11 10 11
20
6 18 1 12 18 1 18 1 18 12 18 1 18 1 18 1 12 18 1 18
20
16 11 17 13 11 17 11 17 11 17 11 17 11 17 11 17 11 17 11 17
20
19 9 5 9 5 9 5 9 5 9 5 9 5 9 5 9 17 9 5 17
20
1 3 4 3 4 3 4...

output:

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

result:

ok 197 lines

Test #117:

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

input:

76
52
9 15 40 15 40 15 40 15 40 15 40 15 40 15 40 16 15 40 15 40 15 40 15 40 15 40 15 16 15 40 15 40 15 40 15 16 15 40 15 40 15 40 15 40 15 40 16 15 40 15 40 15
52
47 11 2 11 2 11 2 11 2 11 2 11 2 11 2 11 2 11 2 11 2 12 11 2 11 2 11 2 11 2 11 2 12 11 2 11 2 11 2 11 2 11 2 11 2 11 2 11 2 12 11 12
52
...

output:

33
21
21
28
39
5
37
20
4
34
34
21
35
32
15
26
30
24
22
9
27
27
33
32
37
28
36
9
7
20
36
34
30
35
21
30
4
30
36
5
38
8
35
22
32
20
20
24
28
26
6
38
38
25
34
19
6
37
6
26
6
9
30
31
22
28
39
37
11
35
11
23
27
31
15
30

result:

ok 76 lines

Test #118:

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

input:

57
70
64 23 59 23 59 23 59 23 59 23 2 23 59 23 59 23 59 23 59 23 59 23 59 2 23 59 23 2 23 59 23 59 23 59 23 59 2 23 59 23 59 23 59 23 59 23 2 23 2 23 59 23 59 23 59 23 59 23 59 23 59 2 23 59 23 59 23 59 23 59
70
29 35 25 35 25 35 25 35 25 35 25 35 25 35 25 35 25 35 25 35 63 35 25 35 25 35 25 35 25 3...

output:

36
48
23
44
42
46
46
46
26
52
50
43
39
51
34
46
31
45
47
9
10
10
9
19
31
47
34
32
35
45
40
33
38
42
33
49
48
34
49
19
43
10
21
47
51
42
44
35
9
43
25
28
13
34
27
45
38

result:

ok 57 lines

Test #119:

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

input:

4
991
381 387 617 387 617 387 617 387 617 387 617 387 617 387 536 387 617 387 617 387 617 387 617 387 617 387 617 387 617 387 617 536 387 617 387 617 387 617 387 617 387 617 387 617 387 617 387 536 387 617 387 617 387 617 387 617 387 617 387 617 387 617 387 617 536 387 617 387 617 387 617 387 617 38...

output:

670
735
734
650

result:

ok 4 lines

Test #120:

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

input:

1
3963
1676 2148 1869 2148 1869 2148 1869 2148 1869 2148 1869 2148 1869 2148 1869 2148 1869 2148 1869 2148 2965 2148 1869 2148 1869 2148 1869 2148 1869 2148 2965 2148 1869 2148 1869 2148 1869 2148 1869 2148 1869 2148 1869 2148 1869 2148 1869 2148 1869 2148 1869 2148 2965 2148 1869 2148 1869 2148 186...

output:

2754

result:

ok single line: '2754'

Test #121:

score: 0
Accepted
time: 41ms
memory: 7680kb

input:

363
10
3 4 2 7 9 1 3 4 2 7
10
4 10 9 4 8 1 4 10 9 4
10
8 4 8 2 1 2 8 4 8 2
10
3 8 9 10 4 1 3 8 9 10
10
9 10 9 5 4 1 9 10 9 5
10
7 6 8 4 2 1 7 6 8 4
10
3 8 7 5 7 1 3 8 7 5
10
2 7 4 3 1 3 2 7 4 3
10
2 7 8 5 4 1 2 7 8 5
10
1 8 1 9 10 2 1 8 1 9
10
4 6 7 4 6 1 4 6 7 4
10
9 6 4 9 10 1 9 6 4 9
10
5 2 5 7 3...

output:

6
6
3
6
4
6
5
5
6
4
6
6
4
2
4
4
6
6
5
6
7
5
7
7
8
3
7
5
7
3
4
7
7
7
7
7
7
5
6
7
6
7
6
7
4
7
5
6
5
7
7
5
7
6
7
6
7
6
7
7
7
4
7
5
6
7
7
6
7
4
3
6
5
7
6
5
6
7
5
7
7
7
7
6
7
5
7
5
7
5
7
4
7
7
6
7
4
7
5
5
7
7
7
5
2
4
7
7
6
7
6
7
5
5
7
5
6
6
3
7
7
6
7
7
6
7
7
7
7
5
5
6
3
7
5
5
5
7
7
7
5
7
5
6
7
5
2
7
7
3
...

result:

ok 363 lines

Test #122:

score: 0
Accepted
time: 22ms
memory: 7632kb

input:

184
21
12 19 5 8 2 10 2 4 5 2 1 12 19 5 8 2 10 2 4 5 2
21
3 13 14 13 4 17 11 14 8 21 1 3 13 14 13 4 17 11 14 8 21
21
11 1 10 17 4 21 20 15 17 9 1 11 1 10 17 4 21 20 15 17 9
21
12 1 2 20 11 7 14 13 20 15 1 12 1 2 20 11 7 14 13 20 15
21
15 7 9 5 3 13 17 7 2 3 1 15 7 9 5 3 13 17 7 2 3
21
21 13 17 6 7 1...

output:

17
18
17
17
17
18
18
18
18
17
17
18
18
17
19
18
18
18
18
18
17
18
18
18
18
17
18
18
18
18
18
18
17
18
18
18
18
18
17
18
18
18
18
18
18
18
17
18
17
17
17
17
17
18
17
17
17
17
18
18
16
15
14
14
15
17
17
18
14
17
16
18
15
17
18
15
16
13
16
16
18
16
16
16
16
16
16
16
16
18
16
16
16
13
14
18
18
17
14
15
...

result:

ok 184 lines

Test #123:

score: 0
Accepted
time: 10ms
memory: 7676kb

input:

73
54
24 13 15 40 35 44 35 54 39 42 35 28 10 42 17 54 3 6 43 49 28 44 47 53 51 48 38 1 24 13 15 40 35 44 35 54 39 42 35 28 10 42 17 54 3 6 43 49 28 44 47 53 51 48
54
42 13 19 31 52 51 19 37 1 25 29 10 36 43 40 27 45 9 29 4 14 42 41 3 17 29 10 1 42 13 19 31 52 51 19 37 1 25 29 10 36 43 40 27 45 9 29 ...

output:

44
48
46
47
45
46
46
46
46
45
46
46
44
46
46
46
46
48
48
46
46
50
48
46
46
47
48
44
44
46
46
50
47
47
46
46
46
46
48
46
47
46
46
48
46
48
44
48
46
48
46
50
47
45
47
47
49
49
47
47
47
47
48
47
47
47
47
49
45
49
47
47
45

result:

ok 73 lines

Test #124:

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

input:

62
64
20 63 64 6 48 63 9 3 45 33 61 32 29 5 21 7 61 57 1 14 6 52 56 64 27 46 5 59 45 22 27 53 1 20 63 64 6 48 63 9 3 45 33 61 32 29 5 21 7 61 57 1 14 6 52 56 64 27 46 5 59 45 22 27
64
58 12 30 56 25 56 3 64 59 17 20 28 6 24 6 18 62 7 20 61 10 8 1 53 14 64 50 6 14 32 40 49 1 58 12 30 56 25 56 3 64 59...

output:

60
59
60
60
59
59
60
60
60
59
58
58
59
59
59
58
59
60
60
60
59
58
59
58
59
60
58
59
59
59
58
59
59
59
60
59
60
60
59
58
59
61
60
60
61
61
61
60
58
61
61
60
60
60
60
60
60
60
61
61
59
60

result:

ok 62 lines

Test #125:

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

input:

4
996
898 416 131 565 916 502 790 624 581 81 42 970 202 252 890 1 519 721 5 532 274 314 272 623 918 797 548 568 969 200 384 469 265 43 706 571 509 636 267 701 207 534 219 701 126 130 633 729 291 509 778 676 637 283 553 482 853 400 246 667 138 925 459 236 840 590 199 886 67 268 761 192 530 535 321 45...

output:

989
989
990
989

result:

ok 4 lines

Test #126:

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

input:

1
3986
3438 1240 2612 3453 3200 3116 592 3920 979 2511 1498 1254 2314 2035 2411 120 3591 524 89 3193 1474 2731 1707 1625 291 604 2581 287 3631 1476 1354 3800 3590 1447 2492 462 2777 901 1796 3202 819 3701 477 1651 3700 2363 371 3910 1874 1069 566 3672 1143 2956 1667 1541 669 3247 116 2085 2354 2122 ...

output:

3974

result:

ok single line: '3974'

Test #127:

score: 0
Accepted
time: 202ms
memory: 7872kb

input:

1869
2
1 2
2
1 2
2
1 2
2
2 1
2
1 2
2
1 2
2
2 1
2
2 1
2
1 2
2
2 1
2
1 2
2
2 1
2
1 2
2
1 2
2
1 2
2
1 2
2
1 2
2
1 2
2
2 1
2
2 1
2
1 2
2
1 2
2
2 1
2
2 1
2
2 1
2
2 1
2
1 2
2
1 2
2
1 2
2
2 1
2
2 1
2
2 1
2
1 2
2
1 2
2
1 2
2
2 1
2
2 1
2
2 1
2
1 2
2
1 2
2
1 2
2
1 2
2
1 2
2
2 1
2
2 1
2
2 1
2
2 1
2
2 1
2
1 2
2...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1869 lines

Test #128:

score: 0
Accepted
time: 45ms
memory: 8128kb

input:

399
9
4 5 7 4 3 6 7 4 2
9
3 4 6 3 1 9 6 1 9
9
4 9 4 9 1 2 8 9 3
9
8 1 5 1 9 4 6 1 6
9
9 6 2 3 2 9 3 1 8
9
3 5 1 3 2 3 5 3 8
9
8 6 4 5 1 5 6 8 7
9
2 1 9 7 4 9 2 4 7
9
4 6 7 4 3 8 3 4 3
10
8 4 9 1 5 3 2 1 6 3
10
2 5 8 6 9 5 3 10 4 3
10
7 3 6 7 10 8 1 4 6 5
10
5 4 5 8 9 3 2 8 9 1
10
5 3 8 9 6 1 6 5 8 6...

output:

5
6
4
4
6
5
6
6
4
7
7
7
6
7
4
7
7
5
6
7
7
7
7
6
5
7
7
6
7
8
7
6
6
6
6
7
5
6
7
5
6
7
7
6
7
5
6
8
5
6
6
5
6
6
6
5
6
5
7
5
6
8
6
7
6
7
7
6
8
6
8
8
7
8
7
6
7
7
5
6
5
6
7
6
6
8
7
6
4
5
4
6
6
5
5
6
6
7
6
7
7
8
5
7
7
7
7
6
7
7
6
5
6
8
6
6
6
6
7
5
7
6
7
4
7
5
8
7
6
7
6
7
6
7
6
7
6
7
6
5
6
7
6
5
6
7
6
7
5
5
...

result:

ok 399 lines

Test #129:

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

input:

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

output:

15
15
16
14
16
11
16
15
16
16
15
15
16
16
17
16
15
16
16
16
15
16
16
15
16
16
16
15
15
16
16
17
16
15
14
15
16
17
16
16
16
16
16
16
15
15
17
16
16
16
16
16
17
15
16
15
14
16
16
16
16
17
14
16
15
16
16
16
16
15
16
16
15
15
14
15
15
15
16
16
15
16
16
16
16
17
17
16
16
14
16
16
15
16
15
15
16
16
16
16
...

result:

ok 194 lines

Test #130:

score: 0
Accepted
time: 10ms
memory: 7688kb

input:

73
54
23 35 38 31 52 9 18 38 2 5 51 13 45 16 21 7 26 5 28 38 15 40 4 21 36 43 35 20 15 25 29 49 9 35 37 24 22 36 53 37 3 41 43 17 47 9 34 49 43 49 50 20 52 43
54
39 7 45 12 5 28 13 7 33 41 12 18 40 16 39 48 28 23 28 13 31 32 51 15 33 5 35 16 43 48 21 38 32 39 22 53 3 48 32 20 14 6 47 26 19 35 36 52 ...

output:

49
49
49
48
49
49
50
48
48
49
47
48
49
49
45
50
49
48
48
47
49
49
49
49
49
49
47
48
49
49
49
51
51
50
50
51
49
49
50
51
49
50
50
49
48
49
49
49
50
50
51
50
49
50
49
51
51
49
50
50
50
50
50
50
50
50
50
51
50
51
50
49
50

result:

ok 73 lines

Test #131:

score: 0
Accepted
time: 9ms
memory: 7624kb

input:

60
66
57 13 61 30 1 17 61 62 28 10 53 3 46 16 32 16 27 62 16 26 25 17 58 62 11 24 66 63 48 57 66 39 3 30 4 28 11 12 37 16 32 34 45 9 28 18 45 29 43 49 27 60 49 33 18 9 57 65 44 7 18 46 65 32 34 51
66
55 59 66 1 7 18 51 63 10 24 37 11 13 59 65 8 14 42 16 42 8 21 6 25 26 5 35 7 56 4 16 53 36 59 66 54 ...

output:

61
60
61
60
61
60
59
60
62
62
61
61
60
61
60
60
61
60
60
61
61
62
62
60
62
61
61
63
61
61
61
61
60
63
63
61
62
62
62
60
61
61
62
62
61
61
62
61
62
60
61
62
62
62
60
62
63
60
62
61

result:

ok 60 lines

Test #132:

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

input:

4
991
213 364 936 696 676 130 278 880 789 228 548 188 418 4 23 607 3 334 546 941 262 431 159 182 79 208 752 682 194 544 445 792 128 60 675 434 238 533 190 730 155 294 145 878 523 971 503 9 116 189 209 128 991 303 444 518 215 59 233 954 767 857 110 785 602 340 230 668 42 384 250 291 496 657 824 793 6...

output:

984
983
983
984

result:

ok 4 lines

Test #133:

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

input:

1
3969
76 3221 2088 895 3256 2928 3772 2327 3736 1121 2082 688 885 2510 1925 2078 244 2195 676 3429 3726 3585 720 3651 3467 3551 2798 1315 3599 2530 2809 1834 649 1466 637 1712 1221 1029 3357 3260 2267 2394 2829 528 959 2751 2455 924 3760 1841 3228 648 1224 2340 520 1712 3057 3065 3685 2206 1260 141...

output:

3960

result:

ok single line: '3960'

Subtask #4:

score: 0
Time Limit Exceeded

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #134:

score: 45
Accepted
time: 1952ms
memory: 7816kb

input:

18040
10
1 9 7 5 8 6 2 10 3 4
10
7 2 1 6 9 8 10 4 3 5
10
3 8 9 5 10 2 1 6 4 7
10
5 4 6 8 7 3 2 1 10 9
10
10 4 3 5 9 7 8 2 6 1
10
7 2 8 10 5 9 3 6 1 4
10
9 10 6 4 8 3 5 7 2 1
10
7 4 2 5 3 1 8 6 10 9
10
1 2 6 9 4 8 5 7 3 10
10
7 10 6 9 2 4 3 5 8 1
10
1 6 10 5 4 2 9 3 7 8
10
2 5 1 6 9 7 10 3 4 8
10
7 9...

output:

8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
...

result:

ok 18040 lines

Test #135:

score: 0
Accepted
time: 1050ms
memory: 7936kb

input:

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

output:

18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
...

result:

ok 9453 lines

Test #136:

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

input:

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

output:

51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
...

result:

ok 3717 lines

Test #137:

score: 0
Accepted
time: 122ms
memory: 8160kb

input:

413
480
260 23 151 329 295 223 401 139 114 47 415 188 472 394 110 356 387 431 469 269 342 33 396 267 340 409 12 280 227 358 217 225 140 13 247 226 242 26 475 135 455 451 224 173 312 232 76 432 18 238 90 236 445 219 305 398 175 204 132 44 382 130 384 168 142 58 390 113 252 425 353 194 338 60 138 433 ...

output:

478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
478
...

result:

ok 413 lines

Test #138:

score: 0
Accepted
time: 127ms
memory: 14368kb

input:

4
49907
12024 16986 33104 35945 48241 36307 1323 12373 37136 49320 8756 27524 4531 49893 9715 8087 40419 15928 34256 48621 5980 23449 234 13703 46237 44290 3166 4462 8167 38137 31607 30436 26941 5372 9942 15906 37040 14452 33483 23864 49456 44242 46712 4971 28208 16091 48599 9357 48785 5988 11726 63...

output:

49905
49905
49906
49906

result:

ok 4 lines

Test #139:

score: 0
Accepted
time: 155ms
memory: 34800kb

input:

1
199804
133843 113543 191526 44946 69331 115930 56656 111705 141051 70500 65756 136744 16660 2767 189370 164441 139440 149290 50569 187511 110690 141187 69642 1117 71407 38284 22713 80569 182917 169087 98525 79832 25213 135400 17051 30432 143231 176597 101359 74992 31131 30920 7293 24254 137527 107...

output:

199802

result:

ok single line: '199802'

Test #140:

score: 0
Accepted
time: 1985ms
memory: 8084kb

input:

18311
10
9 8 7 8 7 5 9 2 9 2
10
7 2 5 7 8 7 10 7 10 7
10
7 2 4 2 7 8 1 3 9 7
10
9 6 9 4 6 4 6 4 9 6
10
8 4 8 9 6 4 9 5 9 5
10
10 9 4 10 6 5 3 5 3 4
10
8 10 8 10 8 6 7 6 7 6
10
6 7 3 9 3 1 3 1 3 2
10
6 9 4 9 6 1 6 1 9 4
10
2 3 1 4 8 3 4 1 2 4
10
2 5 7 1 10 1 10 2 10 1
10
2 6 3 6 5 2 8 5 8 5
10
6 4 3 ...

output:

5
4
6
4
6
6
4
4
5
6
4
6
6
6
6
6
5
6
5
6
6
7
4
6
7
4
6
4
7
5
6
3
2
6
7
3
5
4
6
1
5
5
6
2
6
3
5
3
6
5
5
6
7
7
4
7
7
5
5
6
6
7
2
4
4
5
6
6
6
5
6
5
4
6
5
6
5
6
5
5
6
7
7
4
7
5
7
4
6
6
4
2
4
7
6
5
4
4
5
6
7
5
6
4
7
6
5
5
7
5
2
6
5
2
4
4
6
6
7
6
5
4
5
1
4
6
4
6
3
5
5
5
7
6
6
1
7
5
6
5
6
6
5
5
6
2
5
6
2
6
...

result:

ok 18311 lines

Test #141:

score: 0
Accepted
time: 1075ms
memory: 7548kb

input:

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

output:

16
14
12
15
9
16
16
14
15
14
16
15
14
14
14
14
15
15
10
14
13
10
14
15
16
13
12
10
13
15
13
13
15
11
13
13
16
14
15
15
14
15
14
16
15
14
11
15
14
14
13
16
15
8
9
15
13
14
14
15
11
15
14
12
9
9
14
14
15
13
12
12
15
13
13
12
15
16
10
12
13
15
11
14
16
13
8
14
12
9
15
13
12
14
16
10
10
14
16
10
11
14
1...

result:

ok 9798 lines

Test #142:

score: 0
Accepted
time: 467ms
memory: 7912kb

input:

3746
53
37 15 45 15 50 15 18 45 53 50 53 50 46 7 37 7 37 45 17 7 17 50 47 50 49 33 21 33 18 17 18 13 2 13 2 33 45 33 19 21 19 21 15 2 15 2 50 15 47 33 7 45 2
53
46 44 11 40 5 30 42 30 8 35 21 43 39 43 46 10 46 49 50 49 10 44 27 17 27 45 46 39 31 52 31 21 49 41 49 42 52 31 52 17 11 37 21 37 18 6 17 6...

output:

45
47
46
47
44
49
45
45
43
45
44
44
43
43
46
42
46
45
43
39
48
41
42
44
44
41
44
43
47
45
48
47
45
47
47
47
46
45
45
47
47
42
48
44
45
44
49
39
47
49
46
41
42
44
48
48
43
47
46
43
46
45
46
46
46
49
44
43
46
43
47
41
47
35
43
46
42
43
44
47
47
46
44
47
45
45
43
44
47
47
45
46
44
42
46
44
45
44
46
46
...

result:

ok 3746 lines

Test #143:

score: 0
Accepted
time: 90ms
memory: 9932kb

input:

421
470
167 407 418 367 418 367 357 346 357 70 154 384 154 175 161 393 78 411 199 411 199 411 199 411 452 249 295 294 295 294 295 294 295 262 10 262 400 83 400 83 400 83 358 38 358 38 358 38 98 102 98 102 98 390 418 390 418 390 129 172 129 172 129 172 262 367 262 367 449 57 449 57 449 38 22 38 60 36...

output:

450
421
429
426
439
435
426
437
459
419
433
446
459
460
436
450
461
436
453
423
447
457
436
414
449
438
446
442
455
402
460
448
416
430
447
430
435
442
451
416
433
421
432
427
436
415
433
450
446
425
450
457
447
428
431
458
425
420
433
419
454
427
432
445
440
458
443
428
452
445
421
394
439
450
458
...

result:

ok 421 lines

Test #144:

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

input:

4
49661
27661 15616 11854 15616 11854 15616 11854 15616 11854 15616 11854 15616 11854 15616 11854 15616 11854 15616 11854 15616 11854 15616 11854 15616 11854 15616 11854 15616 11854 15616 11854 15616 11854 15616 11854 15616 11854 15616 11854 15616 11854 15616 11854 15616 11854 15616 11854 15616 1185...

output:

46527
47312
48196
45784

result:

ok 4 lines

Test #145:

score: 0
Accepted
time: 76ms
memory: 22192kb

input:

1
198945
67460 15535 66803 15535 66803 15535 66803 15535 66803 15535 66803 15535 66803 15535 66803 15535 66803 15535 66803 15535 66803 15535 66803 15535 66803 15535 66803 15535 66803 15535 66803 15535 66803 15535 66803 15535 66803 15535 66803 15535 66803 15535 66803 15535 66803 15535 66803 15535 668...

output:

187897

result:

ok single line: '187897'

Test #146:

score: -45
Time Limit Exceeded

input:

19552
10
1 6 1 6 1 6 9 1 6 5
10
9 7 9 7 9 7 10 9 7 3
10
3 4 3 4 3 4 10 3 4 5
10
2 4 2 4 2 4 5 2 4 3
10
9 6 9 6 9 6 10 9 6 3
10
4 3 4 3 4 3 1 4 3 5
10
9 8 9 8 9 8 1 9 8 10
10
4 7 4 7 4 7 2 4 7 5
10
6 7 6 7 6 7 3 6 7 10
10
4 7 4 7 4 7 9 4 7 1
10
3 10 3 10 3 10 7 3 10 9
10
5 1 5 1 5 1 6 5 1 7
10
10 2 1...

output:

5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
...

result: