QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#448949#8578. 과일 게임Issa100 ✓1375ms755284kbC++144.4kb2024-06-20 14:09:592024-06-20 14:09:59

Judging History

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

  • [2024-06-20 14:09:59]
  • 评测
  • 测评结果:100
  • 用时:1375ms
  • 内存:755284kb
  • [2024-06-20 14:09:59]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 1e5 + 100;
const int MOD = 1e9 + 7;
const int L = 30;

vector<deque<pii>> f(deque<pii> a, deque<pii> b){
	// cout << "MERGING ";
	// for(pii x: a) cout << x.first << ' ' << x.second << ", ";
	// cout << " AND ";
	// for(pii x: b) cout << x.first << ' ' << x.second << ", ";
	// cout << endl;;
	while(a.size() && b.size()){
		if(a.back().first == b.front().first){
			a.back().second += b.front().second;
			b.pop_front();
			continue;
		}
		pii x;
		if(a.back() < b.front()){
			if(a.size() == 1 || a[a.size()-2] < a.back()) break;
			x = a.back(); a.pop_back();
		} else{
			if(b.size() == 1 || b[1] < b[0]) break;
			x = b.front(); b.pop_front();
		}
		if(x.second & 1){
			x.second--;
			if(x.second){
				a.push_back(x);
				b.push_front(x);
			}
			// cout << "MERGED" << endl;
			return {a, b};
		}
		x.second >>= 1;
		x.first++;
		if(a.back().first == x.first){
			a.back().second += x.second;
		} else a.push_back(x);
	}
	// cout << "MERGED" << endl;
	for(int i = 0; i < b.size(); i++){
		a.push_back(b[i]);
	}
	return {a};
}

int get(deque<pii> &a){
	// cout << "CALCULATING ";
	// for(pii x: a) cout << x.first << ' ' << x.second << ", ";
	// cout << endl;
	pii left = {0, 0};
	int m = 0;
	while(m + 1 < a.size() && a[m+1].first > a[m].first) m++;
	for(int i = 0; i <= m; i++){
		while(left.first < a[i].first){
			left.first++; left.second >>= 1;
		}
		left.second += a[i].second;
	}
	pii right = {0, 0};
	for(int i = a.size() - 1; i > m; i--){
		while(right.first < a[i].first){
			right.first++;
			right.second >>= 1;
		}
		right.second += a[i].second;
	}
	while(right.first < left.first){
		right.first++;
		right.second >>= 1;
	}
	while(right.first > left.first){
		left.first++;
		left.second >>= 1;
	}
	left.second += right.second;
	while(left.second > 1){
		left.second /= 2;
		left.first++;
	}
	// cout << "CALCULATED" << endl;
	return left.first;
}

int n;
int a[N];
struct asd{
	int ans;
	deque<pii> a, b;
	bool ok;
} d[N * 4];

void calc(asd &a, asd &b, asd &c){
	c.ans = max(a.ans, b.ans);
	vector<deque<pii>> x = f(a.b, b.a);
	for(auto &i: x) c.ans = max(c.ans, get(i));
	c.ok = a.ok & b.ok & (x.size()==1);
	if(a.ok) c.a = x[0];
	else c.a = a.a;
	if(b.ok) c.b = x.back();
	else c.b = b.b;
}

void build(int v = 1, int tl = 1, int tr = n){
	if(tl == tr){
		d[v].ans = a[tl]; d[v].ok = 1;
		d[v].a = d[v].b = {{a[tl], 1}};
	} else{
		int mid = (tl + tr) >> 1;
		build(v<<1, tl, mid);
		build(v<<1|1, mid+1, tr);
		calc(d[v<<1], d[v<<1|1], d[v]);
	}
}

void upd(int i, int x, int v = 1, int tl = 1, int tr = n){
	if(tl == tr){
		a[tl] = x;
		d[v].ans = a[tl]; d[v].ok = 1;
		d[v].a = d[v].b = {{a[tl], 1}};
	} else{
		int mid = (tl + tr) >> 1;
		if(i <= mid) upd(i, x, v<<1, tl, mid);
		else upd(i, x, v<<1|1, mid+1, tr);
		calc(d[v<<1], d[v<<1|1], d[v]);
	}
}

asd res;
void get(int l, int r, int v = 1, int tl = 1, int tr = n){
	if(tr < l || tl > r) return;
	if(l <= tl && tr <= r) calc(res, d[v], res);
	else{
		int mid = (tl + tr) >> 1;
		get(l, r, v<<1, tl, mid);
		get(l, r, v<<1|1, mid+1, tr);
	}
}

void prepare_game(vector<int> A) {
    n = A.size();
    for(int i = 1; i <= n; i++) {
        a[i] = A[i-1];
    }
    // cout << "PREPARE GAME" << endl;
    build();
    // cout << "BUILD DONE" << endl;
}

int play_game(int l, int r) {
	l++; r++;
	res = {0, {}, {}, 1};
	get(l, r);
	// cout << "GAME DONE" << endl;

	return res.ans;
}

void update_game(int i, int x) {
	i++;
	upd(i, x);
	// cout << "UPDATE DONE" << endl;
}

#ifndef ONLINE_JUDGE
//код от #ifndef ONLINE_JUDGE до #endif не будет запускатся в системе
int main(void)
{
    // freopen("input.in", "r", stdin);
    //	freopen("out.out","w",stdout);
    int n; cin >> n;
    vector<int> a;
    for(int i = 1; i <= n; i++) {
        a.push_back(0);
        cin >> a.back();
    }
    prepare_game(a);
    int q; cin >> q;
    while(q--) {
        int t; cin >> t;
        if(t == 1) {
            int i, x;
            cin >> i >> x;
            update_game(i, x);
        } else {
            int l, r;
            cin >> l >> r;
            cout << play_game(l, r) << "\n";
        }
    }
}
#endif

詳細信息

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 115ms
memory: 548196kb

input:

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

output:

3
4
3
3
4
4
4
3
2
3

result:

ok 10 lines

Test #2:

score: 5
Accepted
time: 83ms
memory: 548416kb

input:

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

output:

2
3
3
3
3
3
3
2
3
3

result:

ok 10 lines

Test #3:

score: 5
Accepted
time: 79ms
memory: 548364kb

input:

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

output:

2
2
2
2
3
3
3
4
4
2

result:

ok 10 lines

Test #4:

score: 5
Accepted
time: 91ms
memory: 548408kb

input:

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

output:

2
3
2
2
4
3
3
3
4
4

result:

ok 10 lines

Test #5:

score: 5
Accepted
time: 80ms
memory: 548120kb

input:

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

output:

2
3

result:

ok 2 lines

Test #6:

score: 5
Accepted
time: 87ms
memory: 548104kb

input:

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

output:

1
3
3

result:

ok 3 lines

Test #7:

score: 5
Accepted
time: 79ms
memory: 548400kb

input:

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

output:

10
9
10
11
9
10
9
9
8
11

result:

ok 10 lines

Test #8:

score: 5
Accepted
time: 76ms
memory: 548104kb

input:

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

output:

10
10
10
10
10
11
9
10
10
10

result:

ok 10 lines

Test #9:

score: 5
Accepted
time: 63ms
memory: 548132kb

input:

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

output:

5
5
4

result:

ok 3 lines

Test #10:

score: 5
Accepted
time: 91ms
memory: 548124kb

input:

7
1 1 1 1 2 2 2
5
1 0 6
1 2 4
2 6 4
1 4 6
1 0 6

output:

4
3
4
5

result:

ok 4 lines

Test #11:

score: 5
Accepted
time: 80ms
memory: 548140kb

input:

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

output:

7
8
7
7

result:

ok 4 lines

Test #12:

score: 5
Accepted
time: 88ms
memory: 548120kb

input:

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

output:

5
3
5
5
3

result:

ok 5 lines

Test #13:

score: 5
Accepted
time: 107ms
memory: 548092kb

input:

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

output:

11
8
11

result:

ok 3 lines

Test #14:

score: 5
Accepted
time: 92ms
memory: 548208kb

input:

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

output:

11
10
10
11

result:

ok 4 lines

Test #15:

score: 5
Accepted
time: 83ms
memory: 548108kb

input:

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

output:

7
11
10
10

result:

ok 4 lines

Subtask #2:

score: 6
Accepted

Dependency #1:

100%
Accepted

Test #16:

score: 6
Accepted
time: 135ms
memory: 549636kb

input:

600
1 1 2 2 1 2 1 2 1 1 1 1 2 2 1 2 1 2 1 1 2 1 2 2 2 2 2 2 1 1 2 2 1 1 2 1 2 1 2 2 1 1 2 2 1 2 2 1 1 2 1 1 1 2 2 1 2 1 2 2 2 2 1 2 1 1 1 1 2 1 2 1 2 2 2 1 1 2 2 1 1 1 2 2 2 2 1 2 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 2 2 2 1 2 1 2 2 1 2 1 2 1 1 1 2 1 2 1 2 1 2 1 1 2 2 1 1 1 1 1 2 2 1 1 2 2 2 1 2 1 1 2 2 2 ...

output:

5
5
5
5
5
5
5
5
5
5
5
4
5
5
5
5
5
5
5
5
5
5
5
5
5
4
5
5
5
4
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
4
5
5
5
5
5
5
5
5
5
5
5
4
5
5
4
5
5
5
5
5
5
5
5
5
5
5
3
5
5
5
5
5
5
4
4
5
2
5
5
5
5
5
4
5
5
5
3
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:

ok 600 lines

Test #17:

score: 6
Accepted
time: 146ms
memory: 549368kb

input:

600
2 2 1 2 2 1 2 2 2 2 1 1 2 1 2 1 1 2 1 1 1 2 2 1 1 2 1 1 1 1 1 1 1 1 1 2 1 2 2 2 2 2 2 2 1 1 1 1 1 1 2 2 1 2 1 1 1 1 2 1 2 1 2 2 1 2 2 1 1 1 1 1 1 2 1 1 1 2 1 1 2 1 1 2 2 2 1 2 2 2 2 2 2 1 1 2 1 1 2 2 2 2 2 1 2 1 2 1 1 1 2 1 2 1 2 2 1 2 2 1 1 2 1 2 2 1 2 1 1 2 1 1 1 2 1 1 1 1 2 2 1 2 1 2 2 2 2 1 ...

output:

5
5
5
5
5
5
5
5
5
4
4
5
4
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
2
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
3
5
5
5
5
5
5
5
5
5
5
5
4
5
5
5
5
5
5
5
5
5
5
4
5
5
5
5
5
3
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
4
4
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
4
5
5
5
5
5
...

result:

ok 600 lines

Test #18:

score: 6
Accepted
time: 135ms
memory: 549340kb

input:

600
2 2 1 1 1 2 2 2 1 2 1 2 2 1 2 2 1 1 2 1 2 1 1 2 2 2 1 1 2 2 2 1 1 2 2 1 1 2 1 1 1 2 1 1 2 2 1 1 1 2 1 1 1 2 2 1 2 2 2 1 1 1 1 2 2 1 2 2 1 1 1 1 2 2 1 1 2 1 1 2 1 2 2 2 1 1 2 1 1 1 1 2 2 1 2 1 1 2 2 1 2 1 2 1 1 1 1 1 2 2 1 1 2 1 2 1 2 1 1 1 1 2 2 1 1 2 1 2 2 1 2 2 1 2 2 1 2 2 2 1 2 2 2 2 1 2 2 2 ...

output:

5
5
6
6
6
6
6
5
6
5
6
6
5
6
5
2
6
6
5
4
5
6
4
6
5
6
5
5
6
6
6
6
5
6
6
5
6
6
6
6
5
6
4
5
6
6
6
5
6
5
6
6
6
5
6
6
6
6
5
6
6
5
5
6
6
3
5
6
5
6
4
5
6
6
4
6
4
6
6
6
6
6
5
5
6
6
5
5
5
6
6
6
6
6
6
6
4
6
6
6
6
5
6
6
6
6
6
5
6
6
5
5
5
6
6
6
5
6
6
6
6
5
5
6
6
5
6
6
4
5
6
5
4
6
6
6
5
5
5
5
6
5
6
6
6
5
5
6
6
6
...

result:

ok 600 lines

Test #19:

score: 6
Accepted
time: 136ms
memory: 549348kb

input:

600
1 2 1 1 2 2 2 2 2 1 2 2 2 1 1 1 2 2 2 2 1 1 2 2 1 2 2 2 2 1 1 1 1 2 2 1 1 2 2 1 1 1 1 2 1 2 2 1 1 2 2 2 2 2 1 1 1 2 2 2 2 1 1 1 1 1 1 1 2 1 1 2 1 2 2 2 1 2 1 1 1 1 2 1 2 1 1 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 2 2 2 1 1 2 2 1 2 2 1 1 1 1 2 1 2 1 1 1 1 1 2 2 2 1 2 1 1 1 1 1 1 2 1 1 2 2 2 1 1 2 2 2 1 1 ...

output:

6
5
4
6
6
6
5
6
6
6
6
6
6
6
6
6
6
5
6
6
4
6
5
5
6
6
5
5
3
6
6
5
6
5
5
6
6
6
4
6
6
6
4
5
6
6
4
6
6
4
6
6
6
6
6
3
6
4
5
6
6
6
5
4
6
4
6
6
6
6
6
6
6
6
3
6
5
6
6
6
4
6
5
6
3
6
6
6
5
6
6
6
4
6
6
6
6
6
6
6
6
5
5
6
6
5
6
4
5
4
6
6
5
6
6
4
4
6
6
4
6
6
5
5
6
6
4
6
6
4
6
6
5
6
6
4
6
6
6
5
5
6
6
5
5
6
5
6
5
6
...

result:

ok 600 lines

Test #20:

score: 6
Accepted
time: 136ms
memory: 549368kb

input:

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 1 1 1 1 1 ...

output:

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

result:

ok 299 lines

Test #21:

score: 6
Accepted
time: 107ms
memory: 549388kb

input:

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

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

result:

ok 308 lines

Test #22:

score: 6
Accepted
time: 120ms
memory: 549588kb

input:

600
2 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 4 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 4 2 1 1 2 1 1 3 2 2 4 1 1 1 1 3 1 1 2 2 1 1 1 1 1 1 2 1 1 4 3 3 4 4 3 1 1 ...

output:

10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
...

result:

ok 600 lines

Test #23:

score: 6
Accepted
time: 126ms
memory: 549636kb

input:

600
4 3 3 1 1 1 1 1 1 1 1 2 2 1 1 2 2 2 2 1 1 4 2 1 1 1 1 2 1 1 1 1 3 1 1 1 1 3 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 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 2 1 1 2 6 6 7 6 5 3 3 4 1 1 2 1 1 2 1 1 1 1 1 1 1 1 3 2 2 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 5 ...

output:

10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
11
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
...

result:

ok 600 lines

Test #24:

score: 6
Accepted
time: 131ms
memory: 549344kb

input:

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

output:

12
11
10
11
11
12
12
11
12
8
12
10
11
10
11
11
9
11
11
11
11
10
11
11
12
10
10
10
11
11
10
11
11
11
12
10
12
11
12
11
10
11
12
11
11
11
12
12
10
12
11
12
12
10
11
11
10
11
10
11
11
10
10
10
11
10
11
11
10
12
12
11
10
10
11
12
11
10
12
12
11
11
11
11
12
10
11
12
12
11
12
10
10
10
11
11
11
10
7
11
11
...

result:

ok 296 lines

Test #25:

score: 6
Accepted
time: 124ms
memory: 549336kb

input:

600
3 3 3 2 2 2 2 3 3 3 1 1 1 1 3 3 2 2 2 3 3 3 3 1 1 1 3 3 2 2 2 1 1 1 1 1 3 3 3 3 3 1 1 1 1 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 3 3 3 3 2 2 2 1 1 1 2 2 2 3 3 3 3 3 3 3 1 1 1 3 3 3 3 3 3 3 3 2 2 2 2 1 1 1 2 2 1 1 2 2 2 1 1 1 2 2 2 3 3 3 1 1 1 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 2 2 ...

output:

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

result:

ok 314 lines

Test #26:

score: 6
Accepted
time: 136ms
memory: 549356kb

input:

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

output:

11
7
10
11
10
12
10
12
11
10
10
11
9
12
10
7
12
10
10
12
10
10
6
12
8
10
8
8
10
10
10
12
10
10
12
10
10
8
10
12
12
12
8
10
10
10
10
10
11
10
10
9
10
11
10
9
11
11
8
11
10
10
11
11
7
11
11
11
10
11
10
9
11
11
10
10
10
11
11
7
9
9
11
11
11
9
9
11
10
9
11
11
8
11
11
11
8
9
9
11
11
11
11
3
9
11
10
9
11
...

result:

ok 327 lines

Test #27:

score: 6
Accepted
time: 135ms
memory: 549324kb

input:

600
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 1 1 1 1 1 1 1 1 1 1 1 1 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 4 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 ...

output:

8
7
7
9
11
11
10
11
10
11
10
10
11
11
11
10
8
11
10
10
10
10
10
8
9
10
5
11
7
11
11
11
11
11
10
11
9
11
10
11
11
10
10
11
7
11
8
9
9
11
11
11
11
9
11
10
9
8
11
9
3
10
11
11
10
11
11
6
10
9
8
10
10
10
10
10
9
7
9
10
10
10
9
6
9
8
10
10
8
10
10
7
10
9
10
10
8
9
10
10
9
8
10
10
8
9
10
10
9
10
10
9
10
1...

result:

ok 304 lines

Test #28:

score: 6
Accepted
time: 135ms
memory: 549264kb

input:

600
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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 ...

output:

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

result:

ok 288 lines

Test #29:

score: 6
Accepted
time: 155ms
memory: 549388kb

input:

600
1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 3 2 2 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 2 1 1 1 1 3 2 2 2 2 2 1 1 4 3 1 1 2 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 ...

output:

11
10
10
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
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
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7...

result:

ok 383 lines

Test #30:

score: 6
Accepted
time: 115ms
memory: 549352kb

input:

600
5 1 1 1 1 2 1 1 1 1 2 2 2 1 1 2 3 1 1 2 1 1 2 4 3 3 2 1 1 3 2 2 3 5 1 1 1 1 1 1 1 1 2 2 1 1 1 1 4 4 5 2 1 1 2 2 4 4 4 3 3 3 2 2 5 5 5 5 3 2 1 1 2 1 1 1 1 2 4 3 3 4 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 4 3 3 3 2 1 1 1 1 1 1 ...

output:

11
9
9
9
9
9
9
9
9
9
9
9
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7...

result:

ok 364 lines

Subtask #3:

score: 8
Accepted

Test #31:

score: 8
Accepted
time: 131ms
memory: 555672kb

input:

4000
1 1 1 1 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2 2 2 2 2 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 1 1 1 1 2 2 2 2 2 2 2 2 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 1 1 1 1 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2...

output:

11
12
12
11
10
11
10
11
12
10
9
10
9
9
9
12
11
10
11
9
12
8
9
10
11
12
10
12
10
8
9
10
10
11
10
11
11
11
9
8
5
10
9
9
10
7
10
10
8
9
9
10
10
10
9
10
10
10
6
6
10
9
10
10
8
9
8
9
10
10
9
10
10
9
8
9
9
10
10
9
9
9
8
9
9
8
7
8
10
10
8
8
10
10
8
10
9
6
7
9
9
9
9
7
9
9
9
9
9
9
9
8
9
9
9
9
8
8
8
9
9
8
9
9...

result:

ok 1999 lines

Test #32:

score: 8
Accepted
time: 171ms
memory: 555760kb

input:

4000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 1 1 1 1 2 2 2 2 1 1 1 1...

output:

6
12
11
8
10
11
11
11
11
11
12
7
11
11
11
11
10
11
11
10
11
9
10
11
11
11
9
11
11
10
10
10
11
6
11
11
11
11
10
9
11
9
10
10
10
10
9
8
10
9
7
10
10
8
9
9
9
10
10
9
9
10
9
10
5
5
7
10
10
9
10
10
9
6
9
4
9
8
10
9
10
10
9
9
10
9
10
8
9
10
5
9
10
8
7
7
8
8
8
9
9
9
9
9
9
9
9
8
9
9
8
8
8
9
9
9
8
8
4
9
8
7
...

result:

ok 2018 lines

Test #33:

score: 8
Accepted
time: 151ms
memory: 555740kb

input:

4000
1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 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 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 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 1 1 1 1 1 1 1 1 1 1...

output:

10
10
9
8
10
9
10
9
6
9
10
9
9
9
9
9
9
10
10
7
9
9
9
9
9
9
9
9
10
9
6
8
4
9
9
8
9
9
9
9
9
9
9
9
9
7
9
9
10
8
9
9
9
10
8
8
10
9
9
9
9
8
7
10
9
9
10
8
9
7
8
9
8
9
9
10
10
9
9
9
9
9
9
8
9
9
9
9
9
10
9
9
9
8
8
10
10
7
9
10
9
9
10
4
4
9
9
10
10
7
9
7
10
8
8
9
10
9
9
10
10
10
4
9
8
9
8
9
8
8
9
8
9
9
9
9
9...

result:

ok 1950 lines

Test #34:

score: 8
Accepted
time: 139ms
memory: 555768kb

input:

4000
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 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 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 1 1 1 1 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 1...

output:

9
10
10
9
8
10
9
9
10
9
7
10
8
9
9
10
7
10
9
10
9
10
10
10
9
10
10
9
9
9
10
7
9
9
8
8
7
8
8
8
10
7
10
10
10
10
9
10
9
9
9
9
8
10
8
9
8
10
9
9
8
10
9
10
10
10
9
9
10
9
10
8
9
10
7
9
9
10
10
10
10
10
2
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
6
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
8
9
8
9
8
9
9
9
9
8
9
9
8
9
9
9
9
...

result:

ok 1991 lines

Test #35:

score: 8
Accepted
time: 139ms
memory: 555684kb

input:

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

11
12
12
11
9
11
11
9
10
11
9
7
8
11
11
11
11
11
10
11
10
11
10
11
11
10
10
6
10
10
9
9
10
11
10
7
9
10
9
9
8
10
10
8
10
10
10
6
10
9
10
10
9
10
7
10
10
10
11
10
10
9
9
11
8
11
10
10
10
9
8
8
11
11
10
10
9
10
9
11
9
10
11
11
11
6
11
9
9
9
10
8
10
11
10
11
10
10
10
9
9
8
9
10
10
7
10
9
9
10
8
7
9
10
...

result:

ok 2012 lines

Test #36:

score: 8
Accepted
time: 145ms
memory: 555668kb

input:

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

11
11
9
11
10
11
11
8
10
10
10
11
8
11
10
11
10
10
10
9
11
10
10
10
10
10
9
9
10
10
10
10
10
10
10
8
10
10
10
10
10
10
10
10
10
10
9
10
10
9
10
7
10
10
9
10
10
9
10
10
9
8
4
10
10
9
10
10
9
9
9
9
7
9
9
9
8
10
9
9
10
7
10
9
10
9
9
9
6
9
10
10
10
9
10
10
9
7
9
9
9
9
9
10
9
8
8
9
9
9
9
8
9
8
9
9
9
9
9
...

result:

ok 1988 lines

Test #37:

score: 8
Accepted
time: 131ms
memory: 555760kb

input:

4000
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 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 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:

12
11
12
10
11
12
12
12
12
12
10
11
9
10
9
8
12
12
11
9
8
9
11
11
11
10
11
10
9
9
10
11
10
5
8
9
10
10
10
9
9
10
9
9
10
10
10
10
8
9
9
10
10
10
10
9
9
9
10
5
9
10
10
9
9
9
7
9
10
9
8
9
9
9
10
10
8
7
9
9
9
9
7
9
9
9
8
9
9
10
9
10
10
10
10
9
9
9
9
9
9
10
9
9
9
10
10
9
8
9
9
10
10
10
9
10
10
9
9
8
10
1...

result:

ok 2011 lines

Test #38:

score: 8
Accepted
time: 135ms
memory: 555760kb

input:

4000
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 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 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:

11
7
12
11
9
11
10
11
11
11
9
9
11
11
8
10
11
11
8
12
9
11
11
10
11
8
10
9
10
10
9
11
10
10
9
11
9
11
11
11
10
11
11
10
10
10
11
11
11
8
10
10
10
10
10
3
7
10
10
7
10
10
7
10
9
7
10
10
10
10
8
10
10
10
8
10
9
9
9
9
9
9
9
4
8
8
9
9
8
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
7
5
9
9
6
9
9
9
9
9
9
9
9
9
9...

result:

ok 2010 lines

Test #39:

score: 8
Accepted
time: 139ms
memory: 556384kb

input:

4000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

7
11
12
12
8
12
11
10
11
12
10
10
10
11
11
11
10
9
10
12
12
12
12
11
11
11
12
9
12
11
11
10
10
11
10
8
10
11
7
10
11
10
11
10
11
11
6
11
10
9
9
12
11
10
12
10
11
11
11
5
11
9
12
12
11
8
12
8
10
10
12
11
12
12
12
11
10
11
10
10
9
9
11
9
12
9
11
12
8
11
10
9
12
12
12
11
11
11
11
11
9
12
6
10
9
12
10
1...

result:

ok 1978 lines

Subtask #4:

score: 15
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #40:

score: 15
Accepted
time: 147ms
memory: 556384kb

input:

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

output:

14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
...

result:

ok 4000 lines

Test #41:

score: 15
Accepted
time: 151ms
memory: 556356kb

input:

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

output:

14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
...

result:

ok 4000 lines

Test #42:

score: 15
Accepted
time: 172ms
memory: 555712kb

input:

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

output:

11
11
11
11
11
11
11
10
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
10
11
11
10
11
11
11
11
11
11
11
11
11
9
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
10
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
10
11
11
1...

result:

ok 1983 lines

Test #43:

score: 15
Accepted
time: 131ms
memory: 555880kb

input:

4000
3 3 3 3 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 2 2 2 2 1 1 1 1 1 1 1 1 3 3 3 3 1 1 1 1 3 3 3 3 3 3 3 3 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2 1 1 1 1 3 3 3 3 2 2 2 2 3 3 3 3 2 2 2 2 1 1 1 1 1 1 1 1 2 2 2 2 3 3 3 3 2 2 2 2 1 1 1 1 3 3 3 3 1 1 1 1 3 3 3 3 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 1 1 1...

output:

12
8
9
12
12
11
12
12
10
7
12
12
11
11
11
11
12
11
11
11
11
11
10
10
11
11
9
10
9
10
10
11
10
10
10
10
10
10
9
10
10
10
10
10
10
10
10
10
8
9
10
10
10
7
10
10
10
10
8
8
10
9
7
10
9
10
10
8
10
10
10
9
9
10
9
9
10
10
9
10
9
9
10
10
9
10
8
5
10
8
9
9
9
10
10
8
9
10
9
8
10
9
10
9
10
10
9
10
9
10
10
8
10...

result:

ok 1985 lines

Test #44:

score: 15
Accepted
time: 160ms
memory: 555880kb

input:

4000
1 1 1 1 3 3 3 3 1 1 1 1 3 3 3 3 3 3 3 3 2 2 2 2 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 3 3 3 3 1 1 1 1 2 2 2 2 3 3 3 3 1 1 1 1 2 2 2 2 2 2 2 2 1 1 1 1 3 3 3 3 2 2 2 2 3 3 3 3 3 3 3 3 1 1 1 1...

output:

12
11
13
13
10
12
12
12
9
10
12
12
11
11
11
10
10
12
12
10
9
12
10
11
10
12
12
12
10
10
10
10
10
10
11
8
7
11
10
9
10
10
9
9
6
10
10
10
10
9
8
10
8
10
10
9
10
10
9
9
8
10
10
10
10
6
9
10
10
10
10
10
10
8
10
9
9
10
8
10
9
9
7
9
9
9
9
9
9
9
7
9
9
9
9
9
9
8
9
8
9
9
9
9
9
7
9
9
9
8
7
9
9
9
9
9
9
9
7
5
9...

result:

ok 1991 lines

Test #45:

score: 15
Accepted
time: 141ms
memory: 555892kb

input:

4000
5 5 5 5 5 5 5 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5 5 5 5 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 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 2 2 5 5 5 5 5 5...

output:

10
11
10
11
11
10
11
11
10
11
10
11
10
11
11
11
11
11
11
11
11
11
11
11
11
10
10
11
12
11
9
11
9
10
11
11
10
9
10
10
10
10
11
11
10
11
10
10
11
11
10
11
10
11
11
11
11
11
11
11
10
11
11
11
10
11
11
11
11
8
11
11
11
10
11
11
11
11
11
11
10
11
11
10
10
10
10
11
11
11
10
11
10
10
10
11
10
9
11
11
11
11...

result:

ok 2038 lines

Test #46:

score: 15
Accepted
time: 135ms
memory: 555732kb

input:

4000
3 3 3 4 4 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 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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...

output:

10
10
10
10
10
9
10
10
10
10
10
10
10
10
10
10
10
10
10
9
10
9
10
10
10
10
10
10
10
10
9
10
10
8
10
10
10
10
10
10
10
10
10
10
10
10
9
10
10
10
10
10
10
10
10
10
10
10
10
10
10
9
10
10
10
8
10
10
10
10
10
9
10
9
9
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
9
10
10
10
10
10
10
10
10
9
8
9
...

result:

ok 1956 lines

Test #47:

score: 15
Accepted
time: 147ms
memory: 555764kb

input:

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

14
13
13
9
13
14
13
13
13
13
13
10
13
12
13
13
13
13
13
13
13
13
13
13
13
13
14
13
13
13
13
13
13
13
9
13
13
11
13
6
13
13
13
13
13
13
12
13
13
13
11
13
12
13
12
13
9
13
13
13
14
13
13
13
13
13
13
12
12
13
12
13
13
12
13
13
13
13
13
13
13
13
13
11
9
13
13
13
10
12
13
12
13
13
13
13
12
13
12
13
12
13...

result:

ok 1985 lines

Test #48:

score: 15
Accepted
time: 145ms
memory: 555880kb

input:

4000
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 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...

output:

13
14
14
13
14
10
13
14
14
10
14
8
14
12
13
10
14
14
13
14
14
14
11
13
12
12
14
13
13
13
13
13
13
13
14
14
13
13
14
12
13
13
14
11
13
13
12
12
14
13
14
13
13
11
13
13
13
14
13
13
13
13
13
11
10
13
13
12
13
12
13
13
13
11
13
13
12
13
13
12
13
13
13
12
13
13
13
13
12
13
11
13
13
13
13
13
13
12
10
13
5...

result:

ok 1971 lines

Test #49:

score: 15
Accepted
time: 165ms
memory: 556372kb

input:

4000
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3...

output:

18
17
17
15
18
17
18
15
15
17
17
17
14
17
17
15
15
17
17
17
13
13
16
17
10
10
14
13
17
17
14
14
17
17
14
17
17
9
14
10
17
14
14
17
17
17
17
14
16
13
17
11
11
10
14
17
17
17
13
17
17
14
14
14
11
11
17
13
17
17
17
14
17
16
14
17
14
16
14
13
16
14
14
14
13
16
14
15
13
14
15
13
15
13
14
14
14
14
14
11
1...

result:

ok 2013 lines

Test #50:

score: 15
Accepted
time: 155ms
memory: 556684kb

input:

4000
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4...

output:

18
17
18
17
15
14
16
17
18
11
18
18
15
18
10
13
14
15
17
15
12
16
17
15
10
17
17
15
16
16
17
17
16
17
16
14
15
16
16
16
14
15
16
15
15
13
16
15
15
15
16
16
13
15
15
16
14
16
9
15
11
16
14
16
15
15
15
9
16
15
5
14
16
15
8
16
15
15
15
16
15
16
16
15
15
11
15
15
15
15
15
15
15
14
15
15
15
15
15
15
14
1...

result:

ok 2066 lines

Test #51:

score: 15
Accepted
time: 135ms
memory: 555768kb

input:

4000
6 4 4 1 1 2 3 4 4 3 3 3 3 4 3 3 1 1 1 1 3 5 4 4 4 4 5 5 4 3 2 2 5 3 3 1 1 1 1 1 1 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 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 4 3 1 1 1 1 2 2 1 1 2 3 1 1 1 1 6 4 2 2 1 1 2 4 4 5 5 5 4 4 1 1 2 3 4 4 3 2 2 5 5 6 5 4 4 3 3 2 1 1 3 5 3 2 2 2 2 3 5 1 1...

output:

15
13
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
11
11
11
11
11
11
11
11
11
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
...

result:

ok 1231 lines

Test #52:

score: 15
Accepted
time: 151ms
memory: 555756kb

input:

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

output:

15
14
14
14
14
14
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
...

result:

ok 1419 lines

Subtask #5:

score: 12
Accepted

Dependency #3:

100%
Accepted

Test #53:

score: 12
Accepted
time: 904ms
memory: 754996kb

input:

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

16
16
17
15
17
17
16
17
14
16
17
15
16
16
12
16
14
15
16
16
15
15
16
16
17
15
15
13
16
15
16
16
15
15
14
16
15
15
16
15
16
11
14
16
12
15
16
13
17
15
15
15
11
15
16
17
15
16
14
13
16
14
16
14
13
16
16
13
16
13
14
16
16
16
15
14
14
15
16
12
16
16
17
16
15
13
14
16
9
16
15
16
14
16
16
17
16
15
16
14
1...

result:

ok 49990 lines

Test #54:

score: 12
Accepted
time: 1130ms
memory: 755012kb

input:

100000
2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 2 2 2 2 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 1 1 1 1 1 1 1 1 2 2 2 2 1 1 1 1 1 1 1 1 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 2 2 2...

output:

16
17
17
16
13
15
16
16
16
16
16
16
15
13
15
14
15
15
14
15
15
14
14
13
15
15
14
11
12
15
14
15
15
15
14
15
13
15
14
15
15
15
14
15
15
15
15
15
14
15
14
14
14
14
14
11
14
14
14
13
14
14
14
13
13
14
14
14
14
14
14
14
14
14
14
14
14
14
14
12
14
14
14
14
14
14
11
13
14
14
14
13
13
12
14
14
13
14
13
14
...

result:

ok 50160 lines

Test #55:

score: 12
Accepted
time: 1094ms
memory: 755048kb

input:

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

output:

13
17
16
16
16
15
17
12
15
13
16
15
16
15
16
15
16
6
16
16
14
15
15
15
13
15
14
15
13
15
15
15
15
14
14
13
14
14
14
15
14
14
15
14
14
10
12
15
14
13
15
13
11
14
14
15
15
14
15
15
13
15
13
15
13
14
14
15
15
14
13
15
15
13
12
13
14
14
12
12
14
13
13
14
12
9
14
14
13
13
13
14
14
13
14
13
14
14
14
14
14...

result:

ok 49944 lines

Test #56:

score: 12
Accepted
time: 1083ms
memory: 754992kb

input:

100000
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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 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 1 1 1 1 1 1 1 1 1 1 1 1 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...

output:

10
10
10
10
10
10
10
10
10
10
10
10
10
9
10
9
10
10
10
10
8
9
10
10
10
10
9
10
10
9
9
9
10
10
10
10
10
10
10
10
9
9
10
9
10
10
10
10
10
9
10
10
10
9
10
10
10
9
10
10
9
9
10
10
9
10
10
10
10
10
9
10
10
10
10
9
10
8
10
10
10
10
10
10
9
10
10
10
10
10
10
10
10
9
9
9
10
10
9
9
10
10
10
10
10
10
10
10
10...

result:

ok 49957 lines

Test #57:

score: 12
Accepted
time: 1059ms
memory: 755028kb

input:

100000
2 2 2 2 2 2 2 2 2 2 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 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 1 1 1 1 1 1 2 2 2 2 2 2 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 1 1 1 1 1 1 2 2 2 2 2 2 1 1 1 1 1 1...

output:

10
10
10
10
10
10
10
9
10
9
10
10
9
10
10
9
10
10
10
10
10
10
9
10
10
10
10
10
10
10
10
10
9
9
9
10
9
10
9
10
10
10
9
10
10
10
10
9
10
10
10
10
10
9
10
10
10
10
10
10
10
8
10
10
10
10
10
10
9
10
10
9
10
9
10
10
9
10
9
9
9
9
10
9
10
10
10
10
10
10
10
9
10
10
10
10
10
10
10
8
9
9
10
10
9
10
9
9
10
10
...

result:

ok 50050 lines

Test #58:

score: 12
Accepted
time: 1076ms
memory: 754988kb

input:

100000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 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 1 1 1 1 1 1 1 1 1 1...

output:

10
11
11
11
11
10
11
11
11
11
10
11
11
10
11
11
11
11
11
11
10
11
11
10
11
11
10
11
11
10
11
10
11
11
10
11
10
10
11
10
11
10
10
11
11
10
11
11
10
10
11
10
11
11
11
11
11
11
10
11
11
11
11
11
10
9
10
11
11
11
10
10
11
9
10
11
11
10
11
10
11
11
10
11
11
10
11
10
10
11
10
11
10
11
11
10
10
11
10
10
10...

result:

ok 49858 lines

Test #59:

score: 12
Accepted
time: 1085ms
memory: 755072kb

input:

100000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 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 1 1 1 1 1 1 1...

output:

11
10
11
11
11
11
10
11
10
11
11
10
11
10
11
11
11
11
10
10
9
11
11
11
11
11
11
11
11
11
11
10
10
11
11
11
11
11
9
11
11
11
11
10
11
11
11
11
11
11
11
11
11
11
11
11
11
11
10
11
11
10
11
11
11
10
11
11
11
11
11
11
10
11
11
11
11
10
11
11
11
11
11
10
11
11
11
9
10
11
10
11
11
11
10
11
10
10
10
11
11
...

result:

ok 50023 lines

Test #60:

score: 12
Accepted
time: 1035ms
memory: 754984kb

input:

100000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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...

output:

13
13
13
12
13
13
13
12
12
13
12
12
13
12
13
13
13
12
13
13
13
13
12
13
13
13
13
12
12
13
13
12
13
13
13
13
13
11
11
13
12
13
13
13
11
13
12
12
13
12
12
13
12
13
12
10
13
13
12
13
13
8
13
13
12
13
12
12
12
13
13
13
13
13
12
13
13
13
11
13
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
11
12
13
1...

result:

ok 49972 lines

Test #61:

score: 12
Accepted
time: 1011ms
memory: 754988kb

input:

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

13
14
13
13
14
13
13
13
14
13
13
13
13
13
14
14
13
14
12
13
12
13
12
13
14
13
11
13
13
13
13
14
12
14
12
13
14
13
13
13
13
13
13
13
13
13
13
13
13
12
13
13
12
14
13
13
11
13
13
13
12
12
14
14
12
13
13
12
13
13
13
12
13
13
12
13
13
13
13
13
13
12
12
13
13
13
13
13
13
12
13
13
13
12
13
14
13
13
13
13
...

result:

ok 49988 lines

Test #62:

score: 12
Accepted
time: 983ms
memory: 755284kb

input:

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

17
17
17
16
16
16
15
16
15
16
12
15
16
16
12
14
14
16
16
16
16
16
16
15
16
16
16
16
15
16
16
11
14
16
13
15
15
16
14
16
14
14
16
16
16
15
15
15
15
13
14
15
15
15
15
15
13
15
15
15
13
14
14
12
15
15
15
13
15
14
15
15
14
15
15
15
14
14
13
13
14
15
14
14
14
14
14
14
13
13
14
14
14
13
11
13
13
14
14
14
...

result:

ok 49900 lines

Test #63:

score: 12
Accepted
time: 946ms
memory: 755008kb

input:

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

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

result:

ok 50124 lines

Test #64:

score: 12
Accepted
time: 313ms
memory: 548512kb

input:

200
2 1 2 2 1 2 1 1 2 1 2 2 2 2 1 2 1 1 1 2 2 2 1 1 1 2 1 2 2 2 1 1 1 2 1 2 2 1 2 1 1 1 2 1 1 1 1 2 2 2 2 2 2 1 2 1 2 1 1 1 2 1 1 1 2 1 2 1 2 2 1 1 2 2 2 1 1 2 1 2 2 1 1 2 2 1 1 1 2 2 1 2 1 2 2 2 2 1 2 2 2 2 1 1 2 1 2 1 2 2 1 2 2 2 2 1 1 1 2 2 1 1 1 2 2 1 2 1 1 1 1 1 2 1 2 1 1 2 1 2 2 2 1 1 2 2 1 1 ...

output:

2
2
2
3
3
3
3
3
3
3
3
3
3
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
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:

ok 99996 lines

Test #65:

score: 12
Accepted
time: 294ms
memory: 548540kb

input:

200
2 2 1 2 2 1 1 1 2 1 1 2 1 1 2 1 1 2 2 2 2 1 2 2 1 1 2 2 2 1 1 1 2 1 2 2 1 1 1 2 2 2 2 1 2 1 1 2 2 1 2 1 1 2 1 2 1 2 2 1 1 2 2 1 1 2 2 2 2 1 1 2 1 2 2 1 2 1 1 1 2 1 1 1 2 2 1 1 2 2 1 1 2 1 2 1 1 1 2 1 2 1 2 2 1 1 1 1 1 2 2 2 2 2 1 2 2 2 2 2 1 1 1 1 2 1 2 1 1 1 1 1 2 1 1 2 2 2 1 2 1 1 2 2 1 2 2 2 ...

output:

2
3
3
3
3
3
3
3
3
3
3
4
4
4
4
4
4
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:

ok 99996 lines

Test #66:

score: 12
Accepted
time: 299ms
memory: 548528kb

input:

200
1 2 1 2 1 1 1 2 1 2 1 2 1 2 1 1 1 2 1 1 1 2 2 1 1 2 1 2 2 1 1 2 2 2 2 2 2 1 2 1 2 1 1 2 2 2 1 2 1 1 2 1 1 2 1 1 2 1 2 2 2 1 2 2 1 1 2 1 2 2 2 1 1 1 2 1 1 2 2 1 2 2 2 2 2 2 2 2 1 2 2 1 1 2 2 1 2 1 1 2 2 2 1 2 1 2 1 2 1 1 1 2 1 2 2 2 2 2 2 1 2 1 1 1 2 1 1 1 2 1 1 2 1 1 1 2 1 1 2 2 2 2 1 2 1 1 1 1 ...

output:

1
2
2
2
2
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
4
4
4
4
4
4
4
4
4
4
4
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:

ok 99996 lines

Test #67:

score: 12
Accepted
time: 1120ms
memory: 754992kb

input:

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

output:

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

result:

ok 57236 lines

Test #68:

score: 12
Accepted
time: 1143ms
memory: 755280kb

input:

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

output:

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

result:

ok 57214 lines

Subtask #6:

score: 14
Accepted

Test #69:

score: 14
Accepted
time: 998ms
memory: 755004kb

input:

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

output:

12
11
11
12
12
12
11
12
12
12
12
12
11
12
12
12
12
12
12
12
12
12
12
12
12
11
12
12
11
10
12
12
12
12
12
12
12
12
12
12
12
12
12
11
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
11
12
12
12
12
11
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
11
12
12
12
12
12
12
12
12
12
12
12
...

result:

ok 100000 lines

Test #70:

score: 14
Accepted
time: 994ms
memory: 755212kb

input:

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

output:

12
12
12
12
12
12
12
12
11
12
12
12
11
12
12
12
12
12
12
12
12
12
12
11
12
12
12
12
12
12
12
12
12
11
12
11
12
12
12
11
12
12
12
10
12
12
12
12
12
12
12
11
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
11
12
12
11
12
11
12
12
12
11
11
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
...

result:

ok 100000 lines

Test #71:

score: 14
Accepted
time: 914ms
memory: 755068kb

input:

100000
3 3 3 3 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 2 2 2 2 2 2 2 2 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 3 3 3 3 1 1 1 1 2 2 2 2 3 3 3 3 2 2 2 2 3 3 3 3 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 1 1 1...

output:

17
13
17
18
17
17
17
17
13
18
15
15
17
14
17
14
17
17
17
18
16
16
14
16
16
17
16
17
14
14
18
16
15
17
16
15
16
16
16
17
16
16
18
15
18
16
17
17
12
18
16
18
16
15
15
14
17
16
16
14
16
17
13
18
17
15
18
16
17
16
17
14
13
18
17
17
17
18
17
14
15
15
15
16
17
17
17
17
16
18
16
18
17
18
17
18
14
16
18
10
...

result:

ok 100000 lines

Test #72:

score: 14
Accepted
time: 887ms
memory: 755056kb

input:

100000
2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 1 1 1 1 3 3 3 3 1 1 1 1 1 1 1 1 3 3 3 3 1 1 1 1 2 2 2 2 1 1 1 1 3 3 3 3 3 3 3 3 1 1 1 1 2 2 2 2 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 1 1 1 1 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 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 1 1 1...

output:

16
18
18
16
15
18
18
8
17
16
17
18
17
14
17
17
17
15
15
17
14
17
14
17
16
17
17
17
18
18
16
16
15
18
18
17
14
18
16
12
17
17
16
16
16
16
15
18
16
18
17
16
14
18
18
17
16
18
17
18
12
17
16
17
17
15
17
17
16
18
17
16
15
14
17
17
14
13
16
15
17
16
16
14
17
15
16
17
17
16
18
18
15
17
18
18
17
18
17
10
1...

result:

ok 100000 lines

Test #73:

score: 14
Accepted
time: 911ms
memory: 755200kb

input:

100000
4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 1 1 1 1 1 1 3 3 3 3 3 3 3 4 4 4 4 4 4 4 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 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 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1...

output:

10
10
10
10
10
9
10
10
10
10
10
10
10
10
10
10
10
9
10
10
10
9
10
10
10
10
10
10
10
10
10
10
8
10
10
10
10
10
10
10
10
10
10
10
10
9
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
8
10
10
10
10
10
10
10
10
10
9
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
1...

result:

ok 100000 lines

Test #74:

score: 14
Accepted
time: 977ms
memory: 755276kb

input:

100000
4 4 4 4 4 4 4 4 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3...

output:

10
11
11
11
11
10
11
11
11
10
11
11
11
11
11
8
9
11
11
10
10
10
10
10
11
10
10
11
10
10
10
10
11
11
11
10
10
11
10
11
10
11
11
11
11
10
10
11
11
10
11
10
10
10
11
11
11
11
11
11
10
11
11
11
9
11
11
11
9
11
10
11
11
11
10
11
9
11
10
10
11
10
10
10
10
11
9
11
11
11
11
10
10
11
11
11
11
9
9
11
11
11
11...

result:

ok 100000 lines

Test #75:

score: 14
Accepted
time: 954ms
memory: 755048kb

input:

100000
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5 5 5 5 5 5 5 5...

output:

11
11
12
12
11
11
11
11
12
11
11
11
11
11
11
12
12
12
12
11
12
11
11
11
11
12
11
12
12
12
12
12
11
11
12
12
12
12
12
12
12
12
12
12
12
11
11
12
11
12
12
12
11
11
12
12
12
11
11
12
12
11
12
11
12
11
12
12
12
11
12
11
11
12
12
11
11
11
12
12
12
12
12
11
11
12
11
12
11
11
11
12
12
11
11
11
11
12
12
12
...

result:

ok 100000 lines

Test #76:

score: 14
Accepted
time: 916ms
memory: 755044kb

input:

100000
3 3 3 3 3 3 3 3 3 3 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2...

output:

12
12
12
12
12
12
12
11
12
12
12
12
12
12
12
11
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
11
12
12
11
12
12
12
12
12
12
11
12
12
11
12
12
12
12
12
12
12
12
12
12
12
12
11
12
12
12
12
12
12
12
12
12
12
12
12
12
12
11
11
12
12
11
12
12
12
10
12
12
12
12
12
12
12
12
12
12
11
12
12
12
12
12
11
12
12
...

result:

ok 100000 lines

Test #77:

score: 14
Accepted
time: 885ms
memory: 755096kb

input:

100000
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 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...

output:

18
18
18
17
17
18
18
17
18
17
18
18
18
18
18
18
18
18
17
18
18
18
18
18
18
18
17
18
18
18
18
18
18
18
17
18
18
18
18
18
18
17
18
18
18
17
18
18
18
18
18
18
17
17
18
18
18
18
18
18
18
18
18
17
18
18
18
18
18
13
18
18
18
18
18
18
17
18
18
18
18
18
18
17
18
17
18
18
17
17
18
18
18
16
17
18
18
18
18
17
...

result:

ok 100000 lines

Test #78:

score: 14
Accepted
time: 855ms
memory: 755216kb

input:

100000
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 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 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 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6...

output:

19
7
18
17
18
19
18
19
18
17
18
19
19
19
19
18
18
18
19
18
17
18
19
18
17
18
19
18
18
18
18
18
18
19
18
18
18
19
18
19
19
19
18
18
19
19
19
19
19
19
19
19
18
19
19
18
19
18
19
18
19
19
19
19
19
18
18
18
19
18
18
19
17
18
18
19
19
19
19
18
18
19
18
19
18
19
19
17
19
18
19
19
18
17
19
19
19
18
19
18
1...

result:

ok 100000 lines

Test #79:

score: 14
Accepted
time: 806ms
memory: 755008kb

input:

100000
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...

output:

18
18
16
19
18
18
19
17
19
17
19
19
17
17
19
19
19
17
15
17
17
16
17
18
16
19
19
20
19
19
20
20
17
18
19
18
18
17
20
19
16
19
17
19
19
18
18
19
18
15
17
17
18
19
18
20
15
18
16
18
20
18
17
18
20
16
16
17
20
20
20
16
20
20
9
18
19
20
20
15
20
20
18
20
16
19
19
13
18
20
14
16
15
17
17
18
19
19
19
18
1...

result:

ok 100000 lines

Test #80:

score: 14
Accepted
time: 805ms
memory: 755004kb

input:

100000
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 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...

output:

21
21
22
16
21
16
20
22
22
21
20
21
17
20
17
21
19
20
22
21
21
20
17
21
21
21
21
22
18
23
23
20
20
21
20
21
17
11
18
22
20
20
20
21
22
21
20
20
19
20
22
19
18
21
21
21
21
13
21
21
22
20
21
18
21
22
22
21
20
19
21
21
22
20
21
14
22
18
18
16
22
20
21
21
20
17
21
19
22
18
22
22
19
20
21
20
20
19
19
21
...

result:

ok 100000 lines

Test #81:

score: 14
Accepted
time: 1362ms
memory: 755004kb

input:

100000
6 6 5 4 3 2 2 6 6 4 4 4 4 4 4 5 4 4 4 4 9 5 5 4 4 3 3 4 5 5 5 5 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 3 1 1 2 1 1 2 1 1 2 3 2 2 3 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 5 4 3 3 4 3 3 3 3 4 4 4 4 4 6 3 3 4 3 3 2 2...

output:

19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
...

result:

ok 100000 lines

Test #82:

score: 14
Accepted
time: 1375ms
memory: 754988kb

input:

100000
9 9 3 3 4 1 1 2 3 1 1 1 1 1 1 2 1 1 2 2 1 1 4 5 6 6 5 5 6 6 4 4 5 3 3 4 5 1 1 1 1 3 2 2 1 1 2 3 3 2 2 2 1 1 3 2 2 4 5 2 1 1 3 3 2 2 2 1 1 3 3 1 1 2 2 2 1 1 2 3 2 1 1 2 2 2 2 2 1 1 2 2 2 1 1 2 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 3 2 2 5 4 4 3 3 4 3 1 1 2 4 3 3 4 3 3 1 1 1 1 3 4 4 5 2 1 1 2 2 3 1...

output:

19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
...

result:

ok 100000 lines

Test #83:

score: 14
Accepted
time: 390ms
memory: 549348kb

input:

600
3 4 1 4 1 2 4 4 3 4 3 3 1 3 2 2 3 4 4 1 3 2 2 4 2 3 2 2 2 3 2 4 1 2 2 3 1 3 2 3 2 4 1 4 4 3 3 1 2 4 4 4 3 4 2 3 1 4 3 2 1 4 1 3 4 4 1 1 2 2 4 2 2 2 1 4 3 1 1 3 2 3 1 2 1 1 4 2 1 4 2 2 1 4 2 1 1 1 1 2 4 1 4 3 3 4 2 3 4 3 4 1 3 2 4 3 4 2 2 3 3 4 2 1 2 3 4 3 3 2 2 3 4 4 2 4 1 2 1 2 1 4 1 2 1 4 3 3 ...

output:

3
4
4
4
4
4
4
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
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
...

result:

ok 100000 lines

Test #84:

score: 14
Accepted
time: 384ms
memory: 549368kb

input:

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

output:

6
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
...

result:

ok 100000 lines

Test #85:

score: 14
Accepted
time: 369ms
memory: 549644kb

input:

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

output:

3
3
3
5
5
7
7
8
8
9
9
9
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
...

result:

ok 100000 lines

Subtask #7:

score: 40
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Test #86:

score: 40
Accepted
time: 1231ms
memory: 755072kb

input:

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

output:

12
12
12
12
12
12
12
12
12
11
12
12
12
12
11
12
12
12
12
12
12
11
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
11
12
12
11
12
12
12
12
11
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
11
12
12
12
12
12
12
11
12
12
12
12
11
12
12
12
11
12
12
11
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
11
12
12
...

result:

ok 50017 lines

Test #87:

score: 40
Accepted
time: 1256ms
memory: 755196kb

input:

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

output:

12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
11
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
11
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
11
12
12
12
12
11
12
12
12
12
12
12
12
12
12
12
12
11
12
12
12
12
12
12
11
12
...

result:

ok 49895 lines

Test #88:

score: 40
Accepted
time: 1156ms
memory: 754988kb

input:

100000
1 1 1 1 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 2 2 2 2 1 1 1 1 3 3 3 3 2 2 2 2 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 1 1 1 1 3 3 3 3 1 1 1 1 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 1 1 1 1 2 2 2 2 2 2 2 2 1 1 1 1 2 2 2 2 1 1 1 1 1 1 1 1 2 2 2 2 1 1 1...

output:

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

result:

ok 50042 lines

Test #89:

score: 40
Accepted
time: 1214ms
memory: 755080kb

input:

100000
1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 1 1 1 1 2 2 2 2 3 3 3 3 2 2 2 2 3 3 3 3 3 3 3 3 1 1 1 1 2 2 2 2 2 2 2 2 1 1 1 1 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 3 3 3 3 3 3 3 3 2 2 2 2 3 3 3 3 1 1 1 1 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 2 2 2 2 3 3 3...

output:

17
17
16
14
13
16
16
17
17
16
17
15
10
15
16
15
16
16
15
16
16
16
10
13
15
14
13
15
15
15
15
15
15
15
13
14
15
15
15
14
15
15
15
10
15
15
14
15
15
15
15
12
14
14
14
15
14
15
15
14
13
15
14
13
15
15
14
15
15
14
14
15
15
15
15
13
15
13
15
15
15
14
14
14
15
15
15
14
15
14
14
14
14
14
14
14
14
14
14
14
...

result:

ok 50039 lines

Test #90:

score: 40
Accepted
time: 1160ms
memory: 755092kb

input:

100000
3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 1 1 1 1 1 4 4 4 4 4 4 4 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 4 4 4 4 4 4 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3...

output:

10
10
10
10
10
10
10
9
10
10
10
10
10
10
10
10
10
10
10
10
9
10
10
10
9
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
9
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
9
10
10
10
10
10
10
10
10
10
10
10
10
10
9
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
9
10
10
10
10
1...

result:

ok 49961 lines

Test #91:

score: 40
Accepted
time: 1177ms
memory: 755052kb

input:

100000
2 2 2 2 2 2 2 2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 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 4 4 4 4 4 4 4 2 2 2 2 2 2 2 2 2 2 4 4 4 4 4 4...

output:

11
10
11
10
11
11
10
11
10
11
10
10
11
11
11
11
10
10
11
10
10
11
11
11
10
10
9
10
11
11
11
10
10
11
10
10
11
10
10
10
10
11
11
9
10
11
11
10
10
11
10
11
10
11
10
10
11
11
9
10
10
11
11
10
10
10
10
11
11
10
11
11
10
11
11
10
11
11
11
11
11
10
11
11
11
11
11
11
11
11
11
11
8
11
10
9
10
11
10
11
10
11...

result:

ok 50093 lines

Test #92:

score: 40
Accepted
time: 1129ms
memory: 755060kb

input:

100000
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5...

output:

11
12
12
12
12
11
11
12
12
11
12
12
11
11
11
12
12
12
11
11
12
12
12
11
12
12
12
12
12
11
11
12
12
12
12
12
12
12
11
12
11
11
11
12
11
11
11
12
12
11
11
12
11
12
12
12
12
11
12
12
12
11
12
12
11
12
12
12
12
11
12
12
12
11
12
12
12
12
12
12
12
12
12
11
12
11
12
12
12
12
12
12
12
11
12
12
12
11
12
11
...

result:

ok 50034 lines

Test #93:

score: 40
Accepted
time: 1131ms
memory: 754984kb

input:

100000
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 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 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 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3...

output:

12
12
12
12
11
12
12
12
12
12
12
12
12
12
12
12
11
11
11
12
12
12
12
12
12
11
12
12
12
12
11
12
11
12
12
12
11
12
12
12
12
12
12
12
12
11
12
11
11
12
12
12
12
12
12
12
11
12
12
11
12
11
12
12
11
12
12
11
12
11
12
11
12
11
12
12
12
12
12
11
11
12
12
12
12
11
12
12
11
11
12
11
11
12
12
11
12
11
12
11
...

result:

ok 49931 lines

Test #94:

score: 40
Accepted
time: 1181ms
memory: 755048kb

input:

100000
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10...

output:

18
18
18
18
17
18
18
18
17
17
18
18
16
18
18
18
18
18
18
18
18
18
18
18
17
18
18
18
18
18
18
18
18
18
18
18
18
18
17
18
18
18
18
18
16
18
18
18
18
18
18
16
18
17
18
18
18
18
18
18
18
18
18
18
18
17
18
18
18
17
18
18
16
18
18
18
17
18
18
17
18
18
18
18
18
18
18
18
18
18
18
17
18
18
18
18
18
17
18
18
...

result:

ok 50031 lines

Test #95:

score: 40
Accepted
time: 1189ms
memory: 755004kb

input:

100000
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3...

output:

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

result:

ok 49855 lines

Test #96:

score: 40
Accepted
time: 1064ms
memory: 755004kb

input:

100000
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 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...

output:

24
23
22
23
19
15
21
15
23
18
19
22
22
23
23
21
23
22
23
22
22
19
22
22
19
18
21
23
23
22
17
22
22
17
18
22
22
22
23
22
21
22
22
21
22
22
23
21
21
19
23
22
17
22
22
22
21
22
14
15
22
22
20
15
22
22
16
18
22
22
20
22
21
21
22
21
22
21
22
22
21
22
22
21
22
22
22
21
21
20
21
21
18
21
21
21
21
21
21
21
...

result:

ok 50008 lines

Test #97:

score: 40
Accepted
time: 1097ms
memory: 754976kb

input:

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

23
23
22
20
21
21
21
21
21
21
18
21
21
20
21
20
21
21
20
21
20
20
21
21
21
21
21
21
17
21
20
19
20
21
21
21
19
21
19
20
19
20
19
20
21
21
20
18
20
20
19
17
20
20
19
20
19
20
20
20
20
20
19
20
20
19
13
20
20
20
20
20
18
19
19
20
19
20
20
20
20
20
20
20
19
18
18
20
20
19
19
18
19
20
20
19
20
20
13
20
...

result:

ok 50108 lines

Test #98:

score: 40
Accepted
time: 1292ms
memory: 755008kb

input:

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

output:

20
19
18
17
17
17
17
17
17
17
17
17
17
17
17
17
17
17
16
16
16
16
16
16
16
16
16
16
16
16
16
16
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
...

result:

ok 28522 lines

Test #99:

score: 40
Accepted
time: 1291ms
memory: 755204kb

input:

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

output:

20
18
18
18
18
18
18
18
18
18
17
17
17
17
17
17
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
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 28267 lines

Test #100:

score: 40
Accepted
time: 311ms
memory: 548500kb

input:

200
3 2 4 1 4 3 2 3 4 1 1 2 3 3 1 2 4 1 4 3 4 4 2 3 1 3 4 3 4 1 4 1 3 1 2 1 4 1 2 1 4 3 4 2 4 3 3 2 3 3 3 1 3 1 3 3 3 1 3 1 4 1 2 4 1 3 1 4 1 2 3 2 1 1 4 2 2 2 2 2 4 1 3 1 2 2 4 1 3 3 3 2 4 4 3 1 4 4 2 2 3 3 2 2 3 2 1 1 2 1 3 1 1 1 4 1 2 3 3 3 4 3 1 3 2 2 4 1 4 4 4 3 2 2 1 1 2 2 3 3 2 2 1 3 4 1 3 4 ...

output:

3
3
4
4
4
4
4
4
4
4
4
4
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
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 99996 lines

Test #101:

score: 40
Accepted
time: 326ms
memory: 548496kb

input:

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

output:

1
5
6
7
7
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 99996 lines

Test #102:

score: 40
Accepted
time: 323ms
memory: 548496kb

input:

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

output:

4
7
7
9
9
9
9
9
9
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
11
11
11
...

result:

ok 99996 lines