Submission #741426

# Submission time Handle Problem Language Result Execution time Memory
741426 2023-05-14T05:01:26 Z GusterGoose27 Radio Towers (IOI22_towers) C++17
100 / 100
1776 ms 134320 KB
#include "towers.h"

#include <bits/stdc++.h>

using namespace std;

typedef array<int, 2> pii;

const int MAXN = 1e5;
const int inf = 1e9;
int height[MAXN];
int n;

class path {
public:
	bool tp; // tp = 0 is >= 2, tp = 1 is single
	pii minmax; // tp = 1
	pii lft; // out in, tp = 0
	pii rt; // out in, tp = 0
	int len; // both
	bool par; // 0 is low, 1 is high, tp = 0
	int d;
	path() {}
	path(int i) {
		d = 0;
		tp = 1;
		minmax = pii{height[i], height[i]};
		len = 1;
		par = 0;
	}
	void reverse() {
		swap(lft, rt);
		par ^= (len&1)^1;
	}
	path(path &l, path &r, int d) : d(d) {
		if (l.tp && r.tp) {
			if (l.minmax[1] >= r.minmax[0]+d) {
				lft = pii{l.minmax[1], r.minmax[0]};
				rt = pii{r.minmax[0], l.minmax[1]};
				len = 2;
				par = 1;
				tp = 0;
				return;
			}
			if (l.minmax[0] <= r.minmax[1]-d) {
				lft = pii{l.minmax[0], r.minmax[1]};
				rt = pii{r.minmax[1], l.minmax[0]};
				len = 2;
				par = 0;
				tp = 0;
				return;
			}
			tp = 1;
			minmax = pii{min(l.minmax[0], r.minmax[0]), max(l.minmax[1], r.minmax[1])};
			len = 1;
			return;
		}
		tp = 0;
		bool rev = 0;
		if (l.tp && !r.tp) {
			rev = 1;
			l.reverse();
			r.reverse();
			swap(l, r);
		}
		if (!l.tp && r.tp) {
			bool rhigh = l.par^(l.len&1)^1; // 0 is mn, 1 is high
			if (rhigh && l.rt[0] >= r.minmax[0]+d) {
				lft = l.lft;
				rt = pii{r.minmax[0], l.rt[0]};
				par = l.par;
				len = l.len+1;
			}
			else if (!rhigh && l.rt[0]+d <= r.minmax[1]) {
				lft = l.lft;
				rt = pii{r.minmax[1], l.rt[0]};
				par = l.par;
				len = l.len+1;
			}
			else if (rhigh && l.rt[0] < r.minmax[1]) {
				rt = pii{r.minmax[1], l.rt[1]};
				par = l.par;
				len = l.len;
				if (len > 2) lft = l.lft;
				else lft = pii{l.rt[1], r.minmax[1]};
			}
			else if (!rhigh && l.rt[0] > r.minmax[0]) {
				rt = pii{r.minmax[0], l.rt[1]};
				par = l.par;
				len = l.len;
				if (len > 2) lft = l.lft;
				else lft = pii{l.rt[1], r.minmax[0]};
			}
			else {
				rt = l.rt;
				lft = l.lft;
				len = l.len;
				par = l.par;
			}
			if (rev) {
				swap(l, r);
				l.reverse();
				r.reverse();
				reverse();
			}
			return;
		}
		par = l.par;
		bool lhigh = l.par^(l.len&1)^1;
		bool rhigh = r.par;
		if (lhigh != rhigh) {
			if ((lhigh && l.rt[0] >= d+r.lft[0]) || (!lhigh && l.rt[0]+d <= r.lft[0])) {
				lft = l.lft;
				rt = r.rt;
				len = l.len+r.len;
				return;
			}
			len = l.len+r.len-2;
			if (l.len > 2) lft = l.lft;
			else lft = pii{l.rt[1], r.lft[1]};
			if (r.len > 2) rt = r.rt;
			else rt = pii{r.lft[1], l.rt[1]};
			return;
		}
		len = l.len+r.len-1;
		if ((lhigh && l.rt[0] > r.lft[0]) || (!lhigh && l.rt[0] < r.lft[0])) {
			lft = l.lft;
			if (r.len > 2) rt = r.rt;
			else rt = pii{r.lft[1], l.rt[0]};
			return;
		}
		if (l.len > 2) lft = l.lft;
		else lft = pii{l.rt[1], r.lft[0]};
		rt = r.rt;
	}
};

class stree {
public:
	int lp, rp;
	stree *l = nullptr;
	stree *r = nullptr;
	vector<path> paths;
	stree(int lv, int rv) {
		lp = lv;
		rp = rv;
		if (lp < rp) {
			int mid = (lp+rp)/2;
			l = new stree(lp, mid);
			r = new stree(mid+1, rp);
			int pos[2]; pos[0] = pos[1] = 0;
			for (int i = rp-lp+1; i > 0; i--) {
				bool cand;
				path cur_path;
				bool mx_reached = 0;
				do {
					if (pos[0] == l->paths.size()-1 && pos[1] == r->paths.size()-1) {
						mx_reached = 1;
						break;
					}
					cand = (r->get_cost(pos[1]) < l->get_cost(pos[0]));
					pos[cand]++;
					int d = max(r->get_cost(pos[1]), l->get_cost(pos[0]));
					cur_path = path(l->paths[pos[0]], r->paths[pos[1]], d);
				} while (cur_path.len > i); // fix inf condition
				if (!mx_reached) pos[cand]--;
				int mn = max(l->get_cost(pos[0]-1), r->get_cost(pos[1]-1));
				int mx = min(l->get_cost(pos[0]), r->get_cost(pos[1]));
				while (mx > mn+1) {
					int cur = (mn+mx)/2;
					cur_path = path(l->paths[pos[0]], r->paths[pos[1]], cur);
					if (cur_path.len > i) mn = cur;
					else mx = cur;
				}
				if (mx == min(l->get_cost(pos[0]), r->get_cost(pos[1]))) {
					if (pos[0] == l->paths.size()-1 && pos[1] == r->paths.size()-1) break;
					pos[cand]++;
				}
				paths.push_back(path(l->paths[pos[0]], r->paths[pos[1]], mx));
				i = paths.back().len;
			}
		}
		else {
			paths.push_back(path(lp));
		}
	}
	int get_cost(int p) {
		if (p == paths.size()-1) return inf;
		return paths[p+1].d;
	}
	path* query(int lv, int rv, int d) {
		if (lp > rv || rp < lv) return nullptr;
		if (lp >= lv && rp <= rv) {
			int mn = 0;
			int mx = paths.size();
			// cerr << mn << ' ' << mx << endl;
			while (mx > mn+1) {
				int cur = (mn+mx)/2;
				if (paths[cur].d <= d) mn = cur;
				else mx = cur;
			}
			return &paths[mn];
		}
		path *lq = l->query(lv, rv, d);
		path *rq = r->query(lv, rv, d);
		if (lq == nullptr) return rq;
		if (rq == nullptr) return lq;
		return new path(*lq, *rq, d);
	}
};

stree *tree;

void init(int nn, vector<int> hn) {
	n = nn;
	for (int i = 0; i < n; i++) height[i] = hn[i];
	tree = new stree(0, n-1);
}

int max_towers(int l, int r, int d) {
	path *p = tree->query(l, r, d);
	if (p->len <= 1) return 1;
	return (p->len+1-p->par)/2;
}

Compilation message

towers.cpp: In constructor 'stree::stree(int, int)':
towers.cpp:157:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<path>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  157 |      if (pos[0] == l->paths.size()-1 && pos[1] == r->paths.size()-1) {
      |          ~~~~~~~^~~~~~~~~~~~~~~~~~~~
towers.cpp:157:48: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<path>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  157 |      if (pos[0] == l->paths.size()-1 && pos[1] == r->paths.size()-1) {
      |                                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
towers.cpp:176:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<path>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  176 |      if (pos[0] == l->paths.size()-1 && pos[1] == r->paths.size()-1) break;
      |          ~~~~~~~^~~~~~~~~~~~~~~~~~~~
towers.cpp:176:48: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<path>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  176 |      if (pos[0] == l->paths.size()-1 && pos[1] == r->paths.size()-1) break;
      |                                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
towers.cpp: In member function 'int stree::get_cost(int)':
towers.cpp:188:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<path>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  188 |   if (p == paths.size()-1) return inf;
      |       ~~^~~~~~~~~~~~~~~~~
towers.cpp: In constructor 'stree::stree(int, int)':
towers.cpp:177:14: warning: 'cand' may be used uninitialized in this function [-Wmaybe-uninitialized]
  177 |      pos[cand]++;
      |      ~~~~~~~~^
# Verdict Execution time Memory Grader output
1 Correct 581 ms 47624 KB Output is correct
2 Correct 1141 ms 97076 KB Output is correct
3 Correct 1260 ms 97200 KB Output is correct
4 Correct 1321 ms 97176 KB Output is correct
5 Correct 1399 ms 96976 KB Output is correct
6 Correct 1222 ms 97020 KB Output is correct
7 Correct 1304 ms 97160 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 3 ms 848 KB Output is correct
10 Correct 3 ms 848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 464 KB Output is correct
2 Correct 5 ms 1212 KB Output is correct
3 Correct 6 ms 1240 KB Output is correct
4 Correct 7 ms 1488 KB Output is correct
5 Correct 6 ms 1488 KB Output is correct
6 Correct 7 ms 1444 KB Output is correct
7 Correct 6 ms 1488 KB Output is correct
8 Correct 3 ms 848 KB Output is correct
9 Correct 2 ms 848 KB Output is correct
10 Correct 2 ms 848 KB Output is correct
11 Correct 4 ms 848 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 3 ms 848 KB Output is correct
14 Correct 3 ms 848 KB Output is correct
15 Correct 6 ms 1232 KB Output is correct
16 Correct 9 ms 1488 KB Output is correct
17 Correct 7 ms 1384 KB Output is correct
18 Correct 3 ms 848 KB Output is correct
19 Correct 3 ms 848 KB Output is correct
20 Correct 5 ms 1232 KB Output is correct
21 Correct 6 ms 1488 KB Output is correct
22 Correct 6 ms 1488 KB Output is correct
23 Correct 4 ms 848 KB Output is correct
24 Correct 3 ms 848 KB Output is correct
25 Correct 3 ms 720 KB Output is correct
26 Correct 6 ms 1316 KB Output is correct
27 Correct 8 ms 1236 KB Output is correct
28 Correct 7 ms 1488 KB Output is correct
29 Correct 6 ms 1488 KB Output is correct
30 Correct 9 ms 1436 KB Output is correct
31 Correct 6 ms 1488 KB Output is correct
32 Correct 3 ms 848 KB Output is correct
33 Correct 3 ms 848 KB Output is correct
34 Correct 3 ms 848 KB Output is correct
35 Correct 3 ms 848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 464 KB Output is correct
2 Correct 5 ms 1212 KB Output is correct
3 Correct 6 ms 1240 KB Output is correct
4 Correct 7 ms 1488 KB Output is correct
5 Correct 6 ms 1488 KB Output is correct
6 Correct 7 ms 1444 KB Output is correct
7 Correct 6 ms 1488 KB Output is correct
8 Correct 3 ms 848 KB Output is correct
9 Correct 2 ms 848 KB Output is correct
10 Correct 2 ms 848 KB Output is correct
11 Correct 4 ms 848 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 3 ms 848 KB Output is correct
14 Correct 3 ms 848 KB Output is correct
15 Correct 6 ms 1232 KB Output is correct
16 Correct 9 ms 1488 KB Output is correct
17 Correct 7 ms 1384 KB Output is correct
18 Correct 3 ms 848 KB Output is correct
19 Correct 3 ms 848 KB Output is correct
20 Correct 5 ms 1232 KB Output is correct
21 Correct 6 ms 1488 KB Output is correct
22 Correct 6 ms 1488 KB Output is correct
23 Correct 4 ms 848 KB Output is correct
24 Correct 3 ms 848 KB Output is correct
25 Correct 3 ms 720 KB Output is correct
26 Correct 6 ms 1316 KB Output is correct
27 Correct 8 ms 1236 KB Output is correct
28 Correct 7 ms 1488 KB Output is correct
29 Correct 6 ms 1488 KB Output is correct
30 Correct 9 ms 1436 KB Output is correct
31 Correct 6 ms 1488 KB Output is correct
32 Correct 3 ms 848 KB Output is correct
33 Correct 3 ms 848 KB Output is correct
34 Correct 3 ms 848 KB Output is correct
35 Correct 3 ms 848 KB Output is correct
36 Correct 176 ms 37816 KB Output is correct
37 Correct 277 ms 63580 KB Output is correct
38 Correct 285 ms 63360 KB Output is correct
39 Correct 332 ms 71900 KB Output is correct
40 Correct 317 ms 71956 KB Output is correct
41 Correct 318 ms 71932 KB Output is correct
42 Correct 314 ms 72052 KB Output is correct
43 Correct 107 ms 33080 KB Output is correct
44 Correct 100 ms 33168 KB Output is correct
45 Correct 103 ms 33160 KB Output is correct
46 Correct 122 ms 33148 KB Output is correct
47 Correct 266 ms 63396 KB Output is correct
48 Correct 321 ms 72028 KB Output is correct
49 Correct 336 ms 71968 KB Output is correct
50 Correct 99 ms 33224 KB Output is correct
51 Correct 100 ms 33116 KB Output is correct
52 Correct 306 ms 63664 KB Output is correct
53 Correct 322 ms 71912 KB Output is correct
54 Correct 328 ms 72164 KB Output is correct
55 Correct 109 ms 33208 KB Output is correct
56 Correct 105 ms 33216 KB Output is correct
57 Correct 279 ms 59520 KB Output is correct
58 Correct 270 ms 63488 KB Output is correct
59 Correct 284 ms 63520 KB Output is correct
60 Correct 306 ms 71956 KB Output is correct
61 Correct 310 ms 71960 KB Output is correct
62 Correct 320 ms 71952 KB Output is correct
63 Correct 376 ms 71992 KB Output is correct
64 Correct 108 ms 33148 KB Output is correct
65 Correct 101 ms 33224 KB Output is correct
66 Correct 104 ms 33172 KB Output is correct
67 Correct 101 ms 33192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1205 ms 109312 KB Output is correct
2 Correct 1661 ms 124904 KB Output is correct
3 Correct 1707 ms 124752 KB Output is correct
4 Correct 1776 ms 134016 KB Output is correct
5 Correct 1682 ms 134044 KB Output is correct
6 Correct 1497 ms 134096 KB Output is correct
7 Correct 1560 ms 134056 KB Output is correct
8 Correct 1237 ms 97024 KB Output is correct
9 Correct 1361 ms 97124 KB Output is correct
10 Correct 1170 ms 97072 KB Output is correct
11 Correct 1249 ms 97100 KB Output is correct
12 Correct 1267 ms 97120 KB Output is correct
13 Correct 1307 ms 97184 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 3 ms 848 KB Output is correct
16 Correct 3 ms 848 KB Output is correct
17 Correct 277 ms 63484 KB Output is correct
18 Correct 347 ms 71920 KB Output is correct
19 Correct 335 ms 71992 KB Output is correct
20 Correct 109 ms 33116 KB Output is correct
21 Correct 103 ms 33208 KB Output is correct
22 Correct 268 ms 63484 KB Output is correct
23 Correct 360 ms 71824 KB Output is correct
24 Correct 352 ms 72004 KB Output is correct
25 Correct 114 ms 33200 KB Output is correct
26 Correct 107 ms 33332 KB Output is correct
27 Correct 6 ms 1232 KB Output is correct
28 Correct 6 ms 1480 KB Output is correct
29 Correct 6 ms 1488 KB Output is correct
30 Correct 3 ms 848 KB Output is correct
31 Correct 3 ms 848 KB Output is correct
32 Correct 8 ms 1232 KB Output is correct
33 Correct 7 ms 1384 KB Output is correct
34 Correct 8 ms 1488 KB Output is correct
35 Correct 3 ms 848 KB Output is correct
36 Correct 3 ms 848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 379 ms 14208 KB Output is correct
2 Correct 1109 ms 63572 KB Output is correct
3 Correct 1271 ms 63460 KB Output is correct
4 Correct 1249 ms 71964 KB Output is correct
5 Correct 1203 ms 71988 KB Output is correct
6 Correct 1279 ms 71968 KB Output is correct
7 Correct 1370 ms 71900 KB Output is correct
8 Correct 768 ms 33148 KB Output is correct
9 Correct 1031 ms 33228 KB Output is correct
10 Correct 805 ms 33104 KB Output is correct
11 Correct 1014 ms 33160 KB Output is correct
12 Correct 271 ms 63548 KB Output is correct
13 Correct 316 ms 72036 KB Output is correct
14 Correct 330 ms 71984 KB Output is correct
15 Correct 106 ms 33200 KB Output is correct
16 Correct 101 ms 33136 KB Output is correct
17 Correct 258 ms 59524 KB Output is correct
18 Correct 273 ms 63480 KB Output is correct
19 Correct 271 ms 63540 KB Output is correct
20 Correct 323 ms 71956 KB Output is correct
21 Correct 331 ms 71928 KB Output is correct
22 Correct 325 ms 71980 KB Output is correct
23 Correct 318 ms 72004 KB Output is correct
24 Correct 108 ms 33148 KB Output is correct
25 Correct 107 ms 33196 KB Output is correct
26 Correct 101 ms 33148 KB Output is correct
27 Correct 104 ms 33172 KB Output is correct
28 Correct 5 ms 1232 KB Output is correct
29 Correct 6 ms 1488 KB Output is correct
30 Correct 6 ms 1384 KB Output is correct
31 Correct 3 ms 900 KB Output is correct
32 Correct 3 ms 848 KB Output is correct
33 Correct 3 ms 720 KB Output is correct
34 Correct 6 ms 1300 KB Output is correct
35 Correct 6 ms 1244 KB Output is correct
36 Correct 6 ms 1488 KB Output is correct
37 Correct 7 ms 1488 KB Output is correct
38 Correct 7 ms 1464 KB Output is correct
39 Correct 6 ms 1488 KB Output is correct
40 Correct 3 ms 848 KB Output is correct
41 Correct 3 ms 848 KB Output is correct
42 Correct 3 ms 848 KB Output is correct
43 Correct 3 ms 848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 464 KB Output is correct
2 Correct 5 ms 1212 KB Output is correct
3 Correct 6 ms 1240 KB Output is correct
4 Correct 7 ms 1488 KB Output is correct
5 Correct 6 ms 1488 KB Output is correct
6 Correct 7 ms 1444 KB Output is correct
7 Correct 6 ms 1488 KB Output is correct
8 Correct 3 ms 848 KB Output is correct
9 Correct 2 ms 848 KB Output is correct
10 Correct 2 ms 848 KB Output is correct
11 Correct 4 ms 848 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 3 ms 848 KB Output is correct
14 Correct 3 ms 848 KB Output is correct
15 Correct 6 ms 1232 KB Output is correct
16 Correct 9 ms 1488 KB Output is correct
17 Correct 7 ms 1384 KB Output is correct
18 Correct 3 ms 848 KB Output is correct
19 Correct 3 ms 848 KB Output is correct
20 Correct 5 ms 1232 KB Output is correct
21 Correct 6 ms 1488 KB Output is correct
22 Correct 6 ms 1488 KB Output is correct
23 Correct 4 ms 848 KB Output is correct
24 Correct 3 ms 848 KB Output is correct
25 Correct 3 ms 720 KB Output is correct
26 Correct 6 ms 1316 KB Output is correct
27 Correct 8 ms 1236 KB Output is correct
28 Correct 7 ms 1488 KB Output is correct
29 Correct 6 ms 1488 KB Output is correct
30 Correct 9 ms 1436 KB Output is correct
31 Correct 6 ms 1488 KB Output is correct
32 Correct 3 ms 848 KB Output is correct
33 Correct 3 ms 848 KB Output is correct
34 Correct 3 ms 848 KB Output is correct
35 Correct 3 ms 848 KB Output is correct
36 Correct 176 ms 37816 KB Output is correct
37 Correct 277 ms 63580 KB Output is correct
38 Correct 285 ms 63360 KB Output is correct
39 Correct 332 ms 71900 KB Output is correct
40 Correct 317 ms 71956 KB Output is correct
41 Correct 318 ms 71932 KB Output is correct
42 Correct 314 ms 72052 KB Output is correct
43 Correct 107 ms 33080 KB Output is correct
44 Correct 100 ms 33168 KB Output is correct
45 Correct 103 ms 33160 KB Output is correct
46 Correct 122 ms 33148 KB Output is correct
47 Correct 266 ms 63396 KB Output is correct
48 Correct 321 ms 72028 KB Output is correct
49 Correct 336 ms 71968 KB Output is correct
50 Correct 99 ms 33224 KB Output is correct
51 Correct 100 ms 33116 KB Output is correct
52 Correct 306 ms 63664 KB Output is correct
53 Correct 322 ms 71912 KB Output is correct
54 Correct 328 ms 72164 KB Output is correct
55 Correct 109 ms 33208 KB Output is correct
56 Correct 105 ms 33216 KB Output is correct
57 Correct 279 ms 59520 KB Output is correct
58 Correct 270 ms 63488 KB Output is correct
59 Correct 284 ms 63520 KB Output is correct
60 Correct 306 ms 71956 KB Output is correct
61 Correct 310 ms 71960 KB Output is correct
62 Correct 320 ms 71952 KB Output is correct
63 Correct 376 ms 71992 KB Output is correct
64 Correct 108 ms 33148 KB Output is correct
65 Correct 101 ms 33224 KB Output is correct
66 Correct 104 ms 33172 KB Output is correct
67 Correct 101 ms 33192 KB Output is correct
68 Correct 1205 ms 109312 KB Output is correct
69 Correct 1661 ms 124904 KB Output is correct
70 Correct 1707 ms 124752 KB Output is correct
71 Correct 1776 ms 134016 KB Output is correct
72 Correct 1682 ms 134044 KB Output is correct
73 Correct 1497 ms 134096 KB Output is correct
74 Correct 1560 ms 134056 KB Output is correct
75 Correct 1237 ms 97024 KB Output is correct
76 Correct 1361 ms 97124 KB Output is correct
77 Correct 1170 ms 97072 KB Output is correct
78 Correct 1249 ms 97100 KB Output is correct
79 Correct 1267 ms 97120 KB Output is correct
80 Correct 1307 ms 97184 KB Output is correct
81 Correct 0 ms 208 KB Output is correct
82 Correct 3 ms 848 KB Output is correct
83 Correct 3 ms 848 KB Output is correct
84 Correct 277 ms 63484 KB Output is correct
85 Correct 347 ms 71920 KB Output is correct
86 Correct 335 ms 71992 KB Output is correct
87 Correct 109 ms 33116 KB Output is correct
88 Correct 103 ms 33208 KB Output is correct
89 Correct 268 ms 63484 KB Output is correct
90 Correct 360 ms 71824 KB Output is correct
91 Correct 352 ms 72004 KB Output is correct
92 Correct 114 ms 33200 KB Output is correct
93 Correct 107 ms 33332 KB Output is correct
94 Correct 6 ms 1232 KB Output is correct
95 Correct 6 ms 1480 KB Output is correct
96 Correct 6 ms 1488 KB Output is correct
97 Correct 3 ms 848 KB Output is correct
98 Correct 3 ms 848 KB Output is correct
99 Correct 8 ms 1232 KB Output is correct
100 Correct 7 ms 1384 KB Output is correct
101 Correct 8 ms 1488 KB Output is correct
102 Correct 3 ms 848 KB Output is correct
103 Correct 3 ms 848 KB Output is correct
104 Correct 1452 ms 107064 KB Output is correct
105 Correct 1537 ms 124900 KB Output is correct
106 Correct 1744 ms 124952 KB Output is correct
107 Correct 1714 ms 134000 KB Output is correct
108 Correct 1539 ms 134156 KB Output is correct
109 Correct 1473 ms 134096 KB Output is correct
110 Correct 1452 ms 133964 KB Output is correct
111 Correct 1160 ms 97096 KB Output is correct
112 Correct 1222 ms 97272 KB Output is correct
113 Correct 1262 ms 96984 KB Output is correct
114 Correct 1130 ms 96992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 581 ms 47624 KB Output is correct
2 Correct 1141 ms 97076 KB Output is correct
3 Correct 1260 ms 97200 KB Output is correct
4 Correct 1321 ms 97176 KB Output is correct
5 Correct 1399 ms 96976 KB Output is correct
6 Correct 1222 ms 97020 KB Output is correct
7 Correct 1304 ms 97160 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 3 ms 848 KB Output is correct
10 Correct 3 ms 848 KB Output is correct
11 Correct 2 ms 464 KB Output is correct
12 Correct 5 ms 1212 KB Output is correct
13 Correct 6 ms 1240 KB Output is correct
14 Correct 7 ms 1488 KB Output is correct
15 Correct 6 ms 1488 KB Output is correct
16 Correct 7 ms 1444 KB Output is correct
17 Correct 6 ms 1488 KB Output is correct
18 Correct 3 ms 848 KB Output is correct
19 Correct 2 ms 848 KB Output is correct
20 Correct 2 ms 848 KB Output is correct
21 Correct 4 ms 848 KB Output is correct
22 Correct 0 ms 208 KB Output is correct
23 Correct 3 ms 848 KB Output is correct
24 Correct 3 ms 848 KB Output is correct
25 Correct 6 ms 1232 KB Output is correct
26 Correct 9 ms 1488 KB Output is correct
27 Correct 7 ms 1384 KB Output is correct
28 Correct 3 ms 848 KB Output is correct
29 Correct 3 ms 848 KB Output is correct
30 Correct 5 ms 1232 KB Output is correct
31 Correct 6 ms 1488 KB Output is correct
32 Correct 6 ms 1488 KB Output is correct
33 Correct 4 ms 848 KB Output is correct
34 Correct 3 ms 848 KB Output is correct
35 Correct 3 ms 720 KB Output is correct
36 Correct 6 ms 1316 KB Output is correct
37 Correct 8 ms 1236 KB Output is correct
38 Correct 7 ms 1488 KB Output is correct
39 Correct 6 ms 1488 KB Output is correct
40 Correct 9 ms 1436 KB Output is correct
41 Correct 6 ms 1488 KB Output is correct
42 Correct 3 ms 848 KB Output is correct
43 Correct 3 ms 848 KB Output is correct
44 Correct 3 ms 848 KB Output is correct
45 Correct 3 ms 848 KB Output is correct
46 Correct 176 ms 37816 KB Output is correct
47 Correct 277 ms 63580 KB Output is correct
48 Correct 285 ms 63360 KB Output is correct
49 Correct 332 ms 71900 KB Output is correct
50 Correct 317 ms 71956 KB Output is correct
51 Correct 318 ms 71932 KB Output is correct
52 Correct 314 ms 72052 KB Output is correct
53 Correct 107 ms 33080 KB Output is correct
54 Correct 100 ms 33168 KB Output is correct
55 Correct 103 ms 33160 KB Output is correct
56 Correct 122 ms 33148 KB Output is correct
57 Correct 266 ms 63396 KB Output is correct
58 Correct 321 ms 72028 KB Output is correct
59 Correct 336 ms 71968 KB Output is correct
60 Correct 99 ms 33224 KB Output is correct
61 Correct 100 ms 33116 KB Output is correct
62 Correct 306 ms 63664 KB Output is correct
63 Correct 322 ms 71912 KB Output is correct
64 Correct 328 ms 72164 KB Output is correct
65 Correct 109 ms 33208 KB Output is correct
66 Correct 105 ms 33216 KB Output is correct
67 Correct 279 ms 59520 KB Output is correct
68 Correct 270 ms 63488 KB Output is correct
69 Correct 284 ms 63520 KB Output is correct
70 Correct 306 ms 71956 KB Output is correct
71 Correct 310 ms 71960 KB Output is correct
72 Correct 320 ms 71952 KB Output is correct
73 Correct 376 ms 71992 KB Output is correct
74 Correct 108 ms 33148 KB Output is correct
75 Correct 101 ms 33224 KB Output is correct
76 Correct 104 ms 33172 KB Output is correct
77 Correct 101 ms 33192 KB Output is correct
78 Correct 1205 ms 109312 KB Output is correct
79 Correct 1661 ms 124904 KB Output is correct
80 Correct 1707 ms 124752 KB Output is correct
81 Correct 1776 ms 134016 KB Output is correct
82 Correct 1682 ms 134044 KB Output is correct
83 Correct 1497 ms 134096 KB Output is correct
84 Correct 1560 ms 134056 KB Output is correct
85 Correct 1237 ms 97024 KB Output is correct
86 Correct 1361 ms 97124 KB Output is correct
87 Correct 1170 ms 97072 KB Output is correct
88 Correct 1249 ms 97100 KB Output is correct
89 Correct 1267 ms 97120 KB Output is correct
90 Correct 1307 ms 97184 KB Output is correct
91 Correct 0 ms 208 KB Output is correct
92 Correct 3 ms 848 KB Output is correct
93 Correct 3 ms 848 KB Output is correct
94 Correct 277 ms 63484 KB Output is correct
95 Correct 347 ms 71920 KB Output is correct
96 Correct 335 ms 71992 KB Output is correct
97 Correct 109 ms 33116 KB Output is correct
98 Correct 103 ms 33208 KB Output is correct
99 Correct 268 ms 63484 KB Output is correct
100 Correct 360 ms 71824 KB Output is correct
101 Correct 352 ms 72004 KB Output is correct
102 Correct 114 ms 33200 KB Output is correct
103 Correct 107 ms 33332 KB Output is correct
104 Correct 6 ms 1232 KB Output is correct
105 Correct 6 ms 1480 KB Output is correct
106 Correct 6 ms 1488 KB Output is correct
107 Correct 3 ms 848 KB Output is correct
108 Correct 3 ms 848 KB Output is correct
109 Correct 8 ms 1232 KB Output is correct
110 Correct 7 ms 1384 KB Output is correct
111 Correct 8 ms 1488 KB Output is correct
112 Correct 3 ms 848 KB Output is correct
113 Correct 3 ms 848 KB Output is correct
114 Correct 379 ms 14208 KB Output is correct
115 Correct 1109 ms 63572 KB Output is correct
116 Correct 1271 ms 63460 KB Output is correct
117 Correct 1249 ms 71964 KB Output is correct
118 Correct 1203 ms 71988 KB Output is correct
119 Correct 1279 ms 71968 KB Output is correct
120 Correct 1370 ms 71900 KB Output is correct
121 Correct 768 ms 33148 KB Output is correct
122 Correct 1031 ms 33228 KB Output is correct
123 Correct 805 ms 33104 KB Output is correct
124 Correct 1014 ms 33160 KB Output is correct
125 Correct 271 ms 63548 KB Output is correct
126 Correct 316 ms 72036 KB Output is correct
127 Correct 330 ms 71984 KB Output is correct
128 Correct 106 ms 33200 KB Output is correct
129 Correct 101 ms 33136 KB Output is correct
130 Correct 258 ms 59524 KB Output is correct
131 Correct 273 ms 63480 KB Output is correct
132 Correct 271 ms 63540 KB Output is correct
133 Correct 323 ms 71956 KB Output is correct
134 Correct 331 ms 71928 KB Output is correct
135 Correct 325 ms 71980 KB Output is correct
136 Correct 318 ms 72004 KB Output is correct
137 Correct 108 ms 33148 KB Output is correct
138 Correct 107 ms 33196 KB Output is correct
139 Correct 101 ms 33148 KB Output is correct
140 Correct 104 ms 33172 KB Output is correct
141 Correct 5 ms 1232 KB Output is correct
142 Correct 6 ms 1488 KB Output is correct
143 Correct 6 ms 1384 KB Output is correct
144 Correct 3 ms 900 KB Output is correct
145 Correct 3 ms 848 KB Output is correct
146 Correct 3 ms 720 KB Output is correct
147 Correct 6 ms 1300 KB Output is correct
148 Correct 6 ms 1244 KB Output is correct
149 Correct 6 ms 1488 KB Output is correct
150 Correct 7 ms 1488 KB Output is correct
151 Correct 7 ms 1464 KB Output is correct
152 Correct 6 ms 1488 KB Output is correct
153 Correct 3 ms 848 KB Output is correct
154 Correct 3 ms 848 KB Output is correct
155 Correct 3 ms 848 KB Output is correct
156 Correct 3 ms 848 KB Output is correct
157 Correct 1452 ms 107064 KB Output is correct
158 Correct 1537 ms 124900 KB Output is correct
159 Correct 1744 ms 124952 KB Output is correct
160 Correct 1714 ms 134000 KB Output is correct
161 Correct 1539 ms 134156 KB Output is correct
162 Correct 1473 ms 134096 KB Output is correct
163 Correct 1452 ms 133964 KB Output is correct
164 Correct 1160 ms 97096 KB Output is correct
165 Correct 1222 ms 97272 KB Output is correct
166 Correct 1262 ms 96984 KB Output is correct
167 Correct 1130 ms 96992 KB Output is correct
168 Correct 1 ms 208 KB Output is correct
169 Correct 1026 ms 58492 KB Output is correct
170 Correct 1723 ms 125068 KB Output is correct
171 Correct 1713 ms 124984 KB Output is correct
172 Correct 1711 ms 134320 KB Output is correct
173 Correct 1763 ms 133880 KB Output is correct
174 Correct 1771 ms 134120 KB Output is correct
175 Correct 1625 ms 134016 KB Output is correct
176 Correct 1211 ms 97196 KB Output is correct
177 Correct 1192 ms 97188 KB Output is correct
178 Correct 1077 ms 97224 KB Output is correct
179 Correct 1178 ms 97332 KB Output is correct