Submission #1040883

# Submission time Handle Problem Language Result Execution time Memory
1040883 2024-08-01T11:24:54 Z 42kangaroo Radio Towers (IOI22_towers) C++17
100 / 100
1440 ms 72512 KB
#include "towers.h"
#include "bits/stdc++.h"

using namespace std;

struct SegTeRan {
	vector<int> a;

	int get(int l, int r, int i, int lq, int rq) {
		if (r <= lq || rq <= l) return 0;
		if (lq <= l && r <= rq) return a[i];
		int m = (l + r)/2;
		return max(get(l, m, 2*i + 1, lq, rq), get(m, r, 2*i + 2, lq, rq));
	}

	int set(int l, int r, int i, int k, int v) {
		if (k < l || r <= k) return a[i];
		if (l + 1 == r) return a[i] = v;
		int m = (l + r)/2;
		return a[i] = max(set(l, m, 2*i + 1, k, v), set(m, r, 2*i + 2, k, v));
	}
};


struct SegTeMa{
	vector<int> a;

	int build(int l, int r, int i, vector<int>& in) {
		if (l + 1 == r) return a[i] = in[l];
		int m = (l + r)/2;
		return a[i] = max(build(l, m, 2*i + 1, in), build(m, r, 2*i + 2, in));
	}

	int firLe(int l, int r, int i, int k, int hi) {
		if (l > k) return -1;
		if (a[i] < hi) return -1;
		if (l + 1 == r) return l;
		int m = (l + r)/2;
		int reR = firLe(m, r, 2*i + 2, k, hi);
		if (reR != -1) return reR;
		return firLe(l, m, 2*i + 1, k, hi);
	}

	int firRi(int l, int r, int i, int k, int hi) {
		if (r <= k) return -1;
		if (a[i] < hi) return -1;
		if (l + 1 == r) return l;
		int m = (l + r)/2;
		int reR = firRi(l, m, 2*i + 1, k, hi);
		if (reR != -1) return reR;
		return firRi(m, r, 2*i + 2, k, hi);
	}
};

struct Node {
	int l, r, leR, riR, su, mi, ma;
};

tuple<int,int,int> comb(tuple<int,int,int> l, tuple<int,int,int> r) {
	return {get<0>(l) + get<0>(r), min(get<1>(l), get<1>(r)), max(get<2>(l), get<2>(r))};
}

struct SegTePer{
	vector<Node> a;

	void build(int i, int l, int r) {
		a[i].leR = l; a[i].riR = r; a[i].su = 0;
		a[i].mi = 1e9; a[i].ma = -1;
		if (l + 1 == r) return;
		int m = (l + r)/2;
		a[i].l = a.size();
		a.push_back({});
		build(a[i].l, l, m);
		a[i].r = a.size();
		a.push_back({});
		build(a[i].r, m, r);
	}

	int inc(int i, int k) {
		if (a[i].leR > k || a[i].riR <= k) return i;
		if (a[i].leR + 1 == a[i].riR) {
			a.push_back(a[i]);
			a.back().su++;
			a.back().mi = a.back().ma = a[i].leR;
			return a.size() - 1;
		}
		int le = inc(a[i].l, k), ri = inc(a[i].r, k);
		a.push_back({le, ri, a[i].leR, a[i].riR, a[le].su + a[ri].su, min(a[le].mi, a[ri].mi), max(a[le].ma, a[ri].ma)});
		return a.size() - 1;
	}

	tuple<int,int,int> get(int i, int lq, int rq) {
		if (a[i].riR <= lq || rq <= a[i].leR) return {0, 1e9, -1};
		if (lq <= a[i].leR && a[i].riR <= rq) return {a[i].su, a[i].mi, a[i].ma};
		return comb(get(a[i].l, lq, rq), get(a[i].r, lq, rq));
	}
};


struct DifStr{
	int mi, ma, leD, riD;
};

DifStr comb(DifStr l, DifStr r) {
	return {min(l.mi, r.mi), max(l.ma, r.ma), max(l.leD, max(r.leD, r.ma - l.mi)), max(l.riD, max(r.riD, l.ma - r.mi))};
}

struct SegTeDif {
	vector<DifStr> a;

	DifStr build(int l, int r, int i, vector<int> &in) {
		if (l + 1 == r) return a[i] = {in[l], in[l], 0, 0};
		int m = (l + r) / 2;
		return a[i] = comb(build(l, m, 2 * i + 1, in), build(m, r, 2 * i + 2, in));
	}

	DifStr get(int l, int r, int i, int lq, int rq) {
		if (rq <= l || r <= lq) return {(int)1e9, -1, 0, 0};
		if (lq <= l && r <= rq) return a[i];
		int m = (l + r)/2;
		return comb(get(l, m, 2*i + 1, lq, rq), get(m, r, 2*i + 2, lq,rq));
	}
};

SegTePer perSe;
vector<pair<int,int>> whi;
SegTeMa maSe;
SegTeDif diSe;
int n;
vector<int> h;

void init(int N, std::vector<int> H) {
	n = N;
	h = H;
	maSe = SegTeMa{vector<int>(4*N)};
	SegTeRan raSe{vector<int>(4*N, 0)};
	diSe = SegTeDif{vector<DifStr>(4*N)};
	diSe.build(0, N, 0, H);
	maSe.build(0, N, 0, H);
	vector<int> o(N);
	std::iota(o.begin(), o.end(),0);
	std::sort(o.begin(), o.end(), [&](int l, int r){return H[l] < H[r];});
	vector<pair<int,int>> ch;
	for (int i = 0; i < N; ++i) {
		int l = 0, r = 1e9 + 1;
		while (l + 1 < r) {
			int m = l + (r  - l)/2;
			int leB = maSe.firLe(0, N, 0, o[i], H[o[i]] + m), reB = maSe.firRi(0, N, 0, o[i], H[o[i]] + m);
			if (leB == -1) leB = 0;
			if (reB == -1) reB = N;
			if (raSe.get(0, N, 0, leB, reB) < m) l = m;
			else r = m;
		}
		raSe.set(0, N, 0, o[i], l);
		ch.push_back({l, o[i]});
	}
	std::sort(ch.begin(), ch.end(), greater<>());
	perSe.a.push_back({});
	whi.push_back({1e9 + 1, 0});
	perSe.build(0, 0, N);
	for (int i = 0; i < N; ++i) {
		whi.push_back({ch[i].first, perSe.inc(whi.back().second, ch[i].second)});
	}
}


int max_towers(int L, int R, int D) {
	int to = std::lower_bound(whi.rbegin(), whi.rend(),make_pair(D, 0))->second;
	auto [su, mi, ma] = perSe.get(to, L, R + 1);
	if (su == 0) {
		su = 1;
		int l = L + 1, r = R + 2;
		while (l + 1 < r) {
			int m = (l + r)/2;
			if (diSe.get(0, n, 0, L, m).leD >= D) r = m;
			else l = m;
		}
		if (r <= R) {
			su += (diSe.get(0, n, 0, r - 1, R + 1).riD >= D);
		}
	} else {
		int lB = maSe.firLe(0, n, 0, mi, h[mi] + D), rB = maSe.firRi(0, n, 0, ma, h[ma] + D);
		if (lB > L) {
			su += (diSe.get(0, n, 0, L, lB+ 1).leD >= D);
		}
		if (rB != -1 && rB < R) {
			su += (diSe.get(0, n, 0, rB, R + 1).riD >= D);
		}
	}
	return su;
}
# Verdict Execution time Memory Grader output
1 Correct 684 ms 66352 KB Output is correct
2 Correct 1432 ms 71212 KB Output is correct
3 Correct 1370 ms 70440 KB Output is correct
4 Correct 1368 ms 71216 KB Output is correct
5 Correct 1326 ms 71208 KB Output is correct
6 Correct 1396 ms 71932 KB Output is correct
7 Correct 1281 ms 71208 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 5 ms 1564 KB Output is correct
10 Correct 5 ms 1564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 6 ms 1616 KB Output is correct
3 Correct 6 ms 1564 KB Output is correct
4 Correct 7 ms 1564 KB Output is correct
5 Correct 8 ms 1896 KB Output is correct
6 Correct 7 ms 1564 KB Output is correct
7 Correct 6 ms 1564 KB Output is correct
8 Correct 5 ms 1564 KB Output is correct
9 Correct 5 ms 1628 KB Output is correct
10 Correct 6 ms 1564 KB Output is correct
11 Correct 7 ms 1564 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 5 ms 1564 KB Output is correct
14 Correct 5 ms 1620 KB Output is correct
15 Correct 6 ms 1564 KB Output is correct
16 Correct 6 ms 1564 KB Output is correct
17 Correct 7 ms 1564 KB Output is correct
18 Correct 5 ms 1564 KB Output is correct
19 Correct 5 ms 1564 KB Output is correct
20 Correct 6 ms 1564 KB Output is correct
21 Correct 6 ms 1564 KB Output is correct
22 Correct 6 ms 1564 KB Output is correct
23 Correct 5 ms 1644 KB Output is correct
24 Correct 5 ms 1644 KB Output is correct
25 Correct 3 ms 1020 KB Output is correct
26 Correct 6 ms 1564 KB Output is correct
27 Correct 6 ms 1612 KB Output is correct
28 Correct 7 ms 1564 KB Output is correct
29 Correct 7 ms 1564 KB Output is correct
30 Correct 7 ms 1564 KB Output is correct
31 Correct 8 ms 1564 KB Output is correct
32 Correct 5 ms 1564 KB Output is correct
33 Correct 5 ms 1564 KB Output is correct
34 Correct 5 ms 1632 KB Output is correct
35 Correct 6 ms 1564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 6 ms 1616 KB Output is correct
3 Correct 6 ms 1564 KB Output is correct
4 Correct 7 ms 1564 KB Output is correct
5 Correct 8 ms 1896 KB Output is correct
6 Correct 7 ms 1564 KB Output is correct
7 Correct 6 ms 1564 KB Output is correct
8 Correct 5 ms 1564 KB Output is correct
9 Correct 5 ms 1628 KB Output is correct
10 Correct 6 ms 1564 KB Output is correct
11 Correct 7 ms 1564 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 5 ms 1564 KB Output is correct
14 Correct 5 ms 1620 KB Output is correct
15 Correct 6 ms 1564 KB Output is correct
16 Correct 6 ms 1564 KB Output is correct
17 Correct 7 ms 1564 KB Output is correct
18 Correct 5 ms 1564 KB Output is correct
19 Correct 5 ms 1564 KB Output is correct
20 Correct 6 ms 1564 KB Output is correct
21 Correct 6 ms 1564 KB Output is correct
22 Correct 6 ms 1564 KB Output is correct
23 Correct 5 ms 1644 KB Output is correct
24 Correct 5 ms 1644 KB Output is correct
25 Correct 3 ms 1020 KB Output is correct
26 Correct 6 ms 1564 KB Output is correct
27 Correct 6 ms 1612 KB Output is correct
28 Correct 7 ms 1564 KB Output is correct
29 Correct 7 ms 1564 KB Output is correct
30 Correct 7 ms 1564 KB Output is correct
31 Correct 8 ms 1564 KB Output is correct
32 Correct 5 ms 1564 KB Output is correct
33 Correct 5 ms 1564 KB Output is correct
34 Correct 5 ms 1632 KB Output is correct
35 Correct 6 ms 1564 KB Output is correct
36 Correct 276 ms 67620 KB Output is correct
37 Correct 421 ms 70960 KB Output is correct
38 Correct 419 ms 71468 KB Output is correct
39 Correct 439 ms 70544 KB Output is correct
40 Correct 442 ms 70440 KB Output is correct
41 Correct 426 ms 70960 KB Output is correct
42 Correct 454 ms 72232 KB Output is correct
43 Correct 359 ms 72240 KB Output is correct
44 Correct 330 ms 71292 KB Output is correct
45 Correct 438 ms 71328 KB Output is correct
46 Correct 406 ms 72344 KB Output is correct
47 Correct 421 ms 71988 KB Output is correct
48 Correct 423 ms 71268 KB Output is correct
49 Correct 437 ms 71016 KB Output is correct
50 Correct 331 ms 71560 KB Output is correct
51 Correct 429 ms 70816 KB Output is correct
52 Correct 421 ms 72320 KB Output is correct
53 Correct 439 ms 71668 KB Output is correct
54 Correct 432 ms 71636 KB Output is correct
55 Correct 337 ms 70956 KB Output is correct
56 Correct 450 ms 70700 KB Output is correct
57 Correct 402 ms 69932 KB Output is correct
58 Correct 429 ms 72500 KB Output is correct
59 Correct 430 ms 71068 KB Output is correct
60 Correct 434 ms 71720 KB Output is correct
61 Correct 421 ms 70856 KB Output is correct
62 Correct 440 ms 70524 KB Output is correct
63 Correct 447 ms 70692 KB Output is correct
64 Correct 364 ms 71172 KB Output is correct
65 Correct 321 ms 72236 KB Output is correct
66 Correct 428 ms 72512 KB Output is correct
67 Correct 332 ms 72236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 913 ms 71972 KB Output is correct
2 Correct 1108 ms 71216 KB Output is correct
3 Correct 1116 ms 72232 KB Output is correct
4 Correct 1116 ms 70440 KB Output is correct
5 Correct 1082 ms 71380 KB Output is correct
6 Correct 1076 ms 72208 KB Output is correct
7 Correct 1146 ms 71508 KB Output is correct
8 Correct 1316 ms 71468 KB Output is correct
9 Correct 1285 ms 71224 KB Output is correct
10 Correct 1134 ms 70952 KB Output is correct
11 Correct 1108 ms 70644 KB Output is correct
12 Correct 1252 ms 70564 KB Output is correct
13 Correct 1279 ms 72240 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 5 ms 1652 KB Output is correct
16 Correct 5 ms 1564 KB Output is correct
17 Correct 411 ms 71988 KB Output is correct
18 Correct 423 ms 71212 KB Output is correct
19 Correct 475 ms 72232 KB Output is correct
20 Correct 328 ms 71328 KB Output is correct
21 Correct 354 ms 70696 KB Output is correct
22 Correct 425 ms 71984 KB Output is correct
23 Correct 431 ms 72084 KB Output is correct
24 Correct 434 ms 71452 KB Output is correct
25 Correct 328 ms 71720 KB Output is correct
26 Correct 443 ms 71880 KB Output is correct
27 Correct 9 ms 1564 KB Output is correct
28 Correct 8 ms 1808 KB Output is correct
29 Correct 7 ms 1564 KB Output is correct
30 Correct 5 ms 1564 KB Output is correct
31 Correct 5 ms 1564 KB Output is correct
32 Correct 6 ms 1564 KB Output is correct
33 Correct 6 ms 1564 KB Output is correct
34 Correct 7 ms 1668 KB Output is correct
35 Correct 6 ms 1628 KB Output is correct
36 Correct 5 ms 1564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 239 ms 17980 KB Output is correct
2 Correct 943 ms 71724 KB Output is correct
3 Correct 1006 ms 70760 KB Output is correct
4 Correct 1043 ms 72248 KB Output is correct
5 Correct 963 ms 72232 KB Output is correct
6 Correct 1030 ms 72484 KB Output is correct
7 Correct 1022 ms 71684 KB Output is correct
8 Correct 916 ms 71976 KB Output is correct
9 Correct 904 ms 71400 KB Output is correct
10 Correct 972 ms 72192 KB Output is correct
11 Correct 914 ms 71984 KB Output is correct
12 Correct 443 ms 70700 KB Output is correct
13 Correct 427 ms 70696 KB Output is correct
14 Correct 436 ms 71016 KB Output is correct
15 Correct 337 ms 71212 KB Output is correct
16 Correct 438 ms 70952 KB Output is correct
17 Correct 419 ms 71668 KB Output is correct
18 Correct 422 ms 72500 KB Output is correct
19 Correct 425 ms 70448 KB Output is correct
20 Correct 434 ms 70692 KB Output is correct
21 Correct 436 ms 71888 KB Output is correct
22 Correct 456 ms 71728 KB Output is correct
23 Correct 495 ms 72476 KB Output is correct
24 Correct 341 ms 71472 KB Output is correct
25 Correct 331 ms 70620 KB Output is correct
26 Correct 452 ms 70456 KB Output is correct
27 Correct 379 ms 70564 KB Output is correct
28 Correct 8 ms 1640 KB Output is correct
29 Correct 10 ms 1564 KB Output is correct
30 Correct 11 ms 1644 KB Output is correct
31 Correct 7 ms 1620 KB Output is correct
32 Correct 6 ms 1620 KB Output is correct
33 Correct 3 ms 1104 KB Output is correct
34 Correct 7 ms 1620 KB Output is correct
35 Correct 7 ms 1564 KB Output is correct
36 Correct 11 ms 1564 KB Output is correct
37 Correct 6 ms 1640 KB Output is correct
38 Correct 7 ms 1564 KB Output is correct
39 Correct 8 ms 1564 KB Output is correct
40 Correct 5 ms 1564 KB Output is correct
41 Correct 5 ms 1620 KB Output is correct
42 Correct 9 ms 1564 KB Output is correct
43 Correct 6 ms 1636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 6 ms 1616 KB Output is correct
3 Correct 6 ms 1564 KB Output is correct
4 Correct 7 ms 1564 KB Output is correct
5 Correct 8 ms 1896 KB Output is correct
6 Correct 7 ms 1564 KB Output is correct
7 Correct 6 ms 1564 KB Output is correct
8 Correct 5 ms 1564 KB Output is correct
9 Correct 5 ms 1628 KB Output is correct
10 Correct 6 ms 1564 KB Output is correct
11 Correct 7 ms 1564 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 5 ms 1564 KB Output is correct
14 Correct 5 ms 1620 KB Output is correct
15 Correct 6 ms 1564 KB Output is correct
16 Correct 6 ms 1564 KB Output is correct
17 Correct 7 ms 1564 KB Output is correct
18 Correct 5 ms 1564 KB Output is correct
19 Correct 5 ms 1564 KB Output is correct
20 Correct 6 ms 1564 KB Output is correct
21 Correct 6 ms 1564 KB Output is correct
22 Correct 6 ms 1564 KB Output is correct
23 Correct 5 ms 1644 KB Output is correct
24 Correct 5 ms 1644 KB Output is correct
25 Correct 3 ms 1020 KB Output is correct
26 Correct 6 ms 1564 KB Output is correct
27 Correct 6 ms 1612 KB Output is correct
28 Correct 7 ms 1564 KB Output is correct
29 Correct 7 ms 1564 KB Output is correct
30 Correct 7 ms 1564 KB Output is correct
31 Correct 8 ms 1564 KB Output is correct
32 Correct 5 ms 1564 KB Output is correct
33 Correct 5 ms 1564 KB Output is correct
34 Correct 5 ms 1632 KB Output is correct
35 Correct 6 ms 1564 KB Output is correct
36 Correct 276 ms 67620 KB Output is correct
37 Correct 421 ms 70960 KB Output is correct
38 Correct 419 ms 71468 KB Output is correct
39 Correct 439 ms 70544 KB Output is correct
40 Correct 442 ms 70440 KB Output is correct
41 Correct 426 ms 70960 KB Output is correct
42 Correct 454 ms 72232 KB Output is correct
43 Correct 359 ms 72240 KB Output is correct
44 Correct 330 ms 71292 KB Output is correct
45 Correct 438 ms 71328 KB Output is correct
46 Correct 406 ms 72344 KB Output is correct
47 Correct 421 ms 71988 KB Output is correct
48 Correct 423 ms 71268 KB Output is correct
49 Correct 437 ms 71016 KB Output is correct
50 Correct 331 ms 71560 KB Output is correct
51 Correct 429 ms 70816 KB Output is correct
52 Correct 421 ms 72320 KB Output is correct
53 Correct 439 ms 71668 KB Output is correct
54 Correct 432 ms 71636 KB Output is correct
55 Correct 337 ms 70956 KB Output is correct
56 Correct 450 ms 70700 KB Output is correct
57 Correct 402 ms 69932 KB Output is correct
58 Correct 429 ms 72500 KB Output is correct
59 Correct 430 ms 71068 KB Output is correct
60 Correct 434 ms 71720 KB Output is correct
61 Correct 421 ms 70856 KB Output is correct
62 Correct 440 ms 70524 KB Output is correct
63 Correct 447 ms 70692 KB Output is correct
64 Correct 364 ms 71172 KB Output is correct
65 Correct 321 ms 72236 KB Output is correct
66 Correct 428 ms 72512 KB Output is correct
67 Correct 332 ms 72236 KB Output is correct
68 Correct 913 ms 71972 KB Output is correct
69 Correct 1108 ms 71216 KB Output is correct
70 Correct 1116 ms 72232 KB Output is correct
71 Correct 1116 ms 70440 KB Output is correct
72 Correct 1082 ms 71380 KB Output is correct
73 Correct 1076 ms 72208 KB Output is correct
74 Correct 1146 ms 71508 KB Output is correct
75 Correct 1316 ms 71468 KB Output is correct
76 Correct 1285 ms 71224 KB Output is correct
77 Correct 1134 ms 70952 KB Output is correct
78 Correct 1108 ms 70644 KB Output is correct
79 Correct 1252 ms 70564 KB Output is correct
80 Correct 1279 ms 72240 KB Output is correct
81 Correct 1 ms 344 KB Output is correct
82 Correct 5 ms 1652 KB Output is correct
83 Correct 5 ms 1564 KB Output is correct
84 Correct 411 ms 71988 KB Output is correct
85 Correct 423 ms 71212 KB Output is correct
86 Correct 475 ms 72232 KB Output is correct
87 Correct 328 ms 71328 KB Output is correct
88 Correct 354 ms 70696 KB Output is correct
89 Correct 425 ms 71984 KB Output is correct
90 Correct 431 ms 72084 KB Output is correct
91 Correct 434 ms 71452 KB Output is correct
92 Correct 328 ms 71720 KB Output is correct
93 Correct 443 ms 71880 KB Output is correct
94 Correct 9 ms 1564 KB Output is correct
95 Correct 8 ms 1808 KB Output is correct
96 Correct 7 ms 1564 KB Output is correct
97 Correct 5 ms 1564 KB Output is correct
98 Correct 5 ms 1564 KB Output is correct
99 Correct 6 ms 1564 KB Output is correct
100 Correct 6 ms 1564 KB Output is correct
101 Correct 7 ms 1668 KB Output is correct
102 Correct 6 ms 1628 KB Output is correct
103 Correct 5 ms 1564 KB Output is correct
104 Correct 1008 ms 70444 KB Output is correct
105 Correct 1088 ms 72116 KB Output is correct
106 Correct 1157 ms 71464 KB Output is correct
107 Correct 1129 ms 70756 KB Output is correct
108 Correct 1111 ms 70488 KB Output is correct
109 Correct 1189 ms 71556 KB Output is correct
110 Correct 1069 ms 72448 KB Output is correct
111 Correct 1402 ms 72096 KB Output is correct
112 Correct 1383 ms 71460 KB Output is correct
113 Correct 1420 ms 71672 KB Output is correct
114 Correct 1229 ms 70796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 684 ms 66352 KB Output is correct
2 Correct 1432 ms 71212 KB Output is correct
3 Correct 1370 ms 70440 KB Output is correct
4 Correct 1368 ms 71216 KB Output is correct
5 Correct 1326 ms 71208 KB Output is correct
6 Correct 1396 ms 71932 KB Output is correct
7 Correct 1281 ms 71208 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 5 ms 1564 KB Output is correct
10 Correct 5 ms 1564 KB Output is correct
11 Correct 2 ms 600 KB Output is correct
12 Correct 6 ms 1616 KB Output is correct
13 Correct 6 ms 1564 KB Output is correct
14 Correct 7 ms 1564 KB Output is correct
15 Correct 8 ms 1896 KB Output is correct
16 Correct 7 ms 1564 KB Output is correct
17 Correct 6 ms 1564 KB Output is correct
18 Correct 5 ms 1564 KB Output is correct
19 Correct 5 ms 1628 KB Output is correct
20 Correct 6 ms 1564 KB Output is correct
21 Correct 7 ms 1564 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 5 ms 1564 KB Output is correct
24 Correct 5 ms 1620 KB Output is correct
25 Correct 6 ms 1564 KB Output is correct
26 Correct 6 ms 1564 KB Output is correct
27 Correct 7 ms 1564 KB Output is correct
28 Correct 5 ms 1564 KB Output is correct
29 Correct 5 ms 1564 KB Output is correct
30 Correct 6 ms 1564 KB Output is correct
31 Correct 6 ms 1564 KB Output is correct
32 Correct 6 ms 1564 KB Output is correct
33 Correct 5 ms 1644 KB Output is correct
34 Correct 5 ms 1644 KB Output is correct
35 Correct 3 ms 1020 KB Output is correct
36 Correct 6 ms 1564 KB Output is correct
37 Correct 6 ms 1612 KB Output is correct
38 Correct 7 ms 1564 KB Output is correct
39 Correct 7 ms 1564 KB Output is correct
40 Correct 7 ms 1564 KB Output is correct
41 Correct 8 ms 1564 KB Output is correct
42 Correct 5 ms 1564 KB Output is correct
43 Correct 5 ms 1564 KB Output is correct
44 Correct 5 ms 1632 KB Output is correct
45 Correct 6 ms 1564 KB Output is correct
46 Correct 276 ms 67620 KB Output is correct
47 Correct 421 ms 70960 KB Output is correct
48 Correct 419 ms 71468 KB Output is correct
49 Correct 439 ms 70544 KB Output is correct
50 Correct 442 ms 70440 KB Output is correct
51 Correct 426 ms 70960 KB Output is correct
52 Correct 454 ms 72232 KB Output is correct
53 Correct 359 ms 72240 KB Output is correct
54 Correct 330 ms 71292 KB Output is correct
55 Correct 438 ms 71328 KB Output is correct
56 Correct 406 ms 72344 KB Output is correct
57 Correct 421 ms 71988 KB Output is correct
58 Correct 423 ms 71268 KB Output is correct
59 Correct 437 ms 71016 KB Output is correct
60 Correct 331 ms 71560 KB Output is correct
61 Correct 429 ms 70816 KB Output is correct
62 Correct 421 ms 72320 KB Output is correct
63 Correct 439 ms 71668 KB Output is correct
64 Correct 432 ms 71636 KB Output is correct
65 Correct 337 ms 70956 KB Output is correct
66 Correct 450 ms 70700 KB Output is correct
67 Correct 402 ms 69932 KB Output is correct
68 Correct 429 ms 72500 KB Output is correct
69 Correct 430 ms 71068 KB Output is correct
70 Correct 434 ms 71720 KB Output is correct
71 Correct 421 ms 70856 KB Output is correct
72 Correct 440 ms 70524 KB Output is correct
73 Correct 447 ms 70692 KB Output is correct
74 Correct 364 ms 71172 KB Output is correct
75 Correct 321 ms 72236 KB Output is correct
76 Correct 428 ms 72512 KB Output is correct
77 Correct 332 ms 72236 KB Output is correct
78 Correct 913 ms 71972 KB Output is correct
79 Correct 1108 ms 71216 KB Output is correct
80 Correct 1116 ms 72232 KB Output is correct
81 Correct 1116 ms 70440 KB Output is correct
82 Correct 1082 ms 71380 KB Output is correct
83 Correct 1076 ms 72208 KB Output is correct
84 Correct 1146 ms 71508 KB Output is correct
85 Correct 1316 ms 71468 KB Output is correct
86 Correct 1285 ms 71224 KB Output is correct
87 Correct 1134 ms 70952 KB Output is correct
88 Correct 1108 ms 70644 KB Output is correct
89 Correct 1252 ms 70564 KB Output is correct
90 Correct 1279 ms 72240 KB Output is correct
91 Correct 1 ms 344 KB Output is correct
92 Correct 5 ms 1652 KB Output is correct
93 Correct 5 ms 1564 KB Output is correct
94 Correct 411 ms 71988 KB Output is correct
95 Correct 423 ms 71212 KB Output is correct
96 Correct 475 ms 72232 KB Output is correct
97 Correct 328 ms 71328 KB Output is correct
98 Correct 354 ms 70696 KB Output is correct
99 Correct 425 ms 71984 KB Output is correct
100 Correct 431 ms 72084 KB Output is correct
101 Correct 434 ms 71452 KB Output is correct
102 Correct 328 ms 71720 KB Output is correct
103 Correct 443 ms 71880 KB Output is correct
104 Correct 9 ms 1564 KB Output is correct
105 Correct 8 ms 1808 KB Output is correct
106 Correct 7 ms 1564 KB Output is correct
107 Correct 5 ms 1564 KB Output is correct
108 Correct 5 ms 1564 KB Output is correct
109 Correct 6 ms 1564 KB Output is correct
110 Correct 6 ms 1564 KB Output is correct
111 Correct 7 ms 1668 KB Output is correct
112 Correct 6 ms 1628 KB Output is correct
113 Correct 5 ms 1564 KB Output is correct
114 Correct 239 ms 17980 KB Output is correct
115 Correct 943 ms 71724 KB Output is correct
116 Correct 1006 ms 70760 KB Output is correct
117 Correct 1043 ms 72248 KB Output is correct
118 Correct 963 ms 72232 KB Output is correct
119 Correct 1030 ms 72484 KB Output is correct
120 Correct 1022 ms 71684 KB Output is correct
121 Correct 916 ms 71976 KB Output is correct
122 Correct 904 ms 71400 KB Output is correct
123 Correct 972 ms 72192 KB Output is correct
124 Correct 914 ms 71984 KB Output is correct
125 Correct 443 ms 70700 KB Output is correct
126 Correct 427 ms 70696 KB Output is correct
127 Correct 436 ms 71016 KB Output is correct
128 Correct 337 ms 71212 KB Output is correct
129 Correct 438 ms 70952 KB Output is correct
130 Correct 419 ms 71668 KB Output is correct
131 Correct 422 ms 72500 KB Output is correct
132 Correct 425 ms 70448 KB Output is correct
133 Correct 434 ms 70692 KB Output is correct
134 Correct 436 ms 71888 KB Output is correct
135 Correct 456 ms 71728 KB Output is correct
136 Correct 495 ms 72476 KB Output is correct
137 Correct 341 ms 71472 KB Output is correct
138 Correct 331 ms 70620 KB Output is correct
139 Correct 452 ms 70456 KB Output is correct
140 Correct 379 ms 70564 KB Output is correct
141 Correct 8 ms 1640 KB Output is correct
142 Correct 10 ms 1564 KB Output is correct
143 Correct 11 ms 1644 KB Output is correct
144 Correct 7 ms 1620 KB Output is correct
145 Correct 6 ms 1620 KB Output is correct
146 Correct 3 ms 1104 KB Output is correct
147 Correct 7 ms 1620 KB Output is correct
148 Correct 7 ms 1564 KB Output is correct
149 Correct 11 ms 1564 KB Output is correct
150 Correct 6 ms 1640 KB Output is correct
151 Correct 7 ms 1564 KB Output is correct
152 Correct 8 ms 1564 KB Output is correct
153 Correct 5 ms 1564 KB Output is correct
154 Correct 5 ms 1620 KB Output is correct
155 Correct 9 ms 1564 KB Output is correct
156 Correct 6 ms 1636 KB Output is correct
157 Correct 1008 ms 70444 KB Output is correct
158 Correct 1088 ms 72116 KB Output is correct
159 Correct 1157 ms 71464 KB Output is correct
160 Correct 1129 ms 70756 KB Output is correct
161 Correct 1111 ms 70488 KB Output is correct
162 Correct 1189 ms 71556 KB Output is correct
163 Correct 1069 ms 72448 KB Output is correct
164 Correct 1402 ms 72096 KB Output is correct
165 Correct 1383 ms 71460 KB Output is correct
166 Correct 1420 ms 71672 KB Output is correct
167 Correct 1229 ms 70796 KB Output is correct
168 Correct 1 ms 344 KB Output is correct
169 Correct 598 ms 34532 KB Output is correct
170 Correct 1175 ms 71000 KB Output is correct
171 Correct 1244 ms 71464 KB Output is correct
172 Correct 1196 ms 71480 KB Output is correct
173 Correct 1209 ms 70704 KB Output is correct
174 Correct 1220 ms 71464 KB Output is correct
175 Correct 1375 ms 72232 KB Output is correct
176 Correct 1385 ms 71144 KB Output is correct
177 Correct 1360 ms 71464 KB Output is correct
178 Correct 1440 ms 71984 KB Output is correct
179 Correct 1356 ms 70512 KB Output is correct