#include "towers.h"
#include <bits/stdc++.h>
const int OO = 0;
typedef long long ll;
using namespace std;
struct info {
int len[2][2];
int l, r;
info(int x = -1, int i = 0) {
len[0][0] = len[1][1] = -1e9;
len[0][1] = len[1][0] = -1e9;
l = 1e9, r = -1e9;
if (x == 0) {
l = r = i;
len[0][0] = 1;
}
if (x == 1) {
l = r = i;
len[1][1] = 1;
}
}
info operator * (const info &a) const {
info res;
res.l = min(l, a.l);
res.r = max(r, a.r);
for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) {
res.len[i][j] = max(max(res.len[i][j], len[i][j]), a.len[i][j]);
}
for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) for (int k = 0; k < 2; k++) {
res.len[i][k] = max(res.len[i][k], len[i][j] + a.len[1 ^ j][k]);
}
return res;
}
void print() {
for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) {
cout << i << " -> " << j << ": " << len[i][j] << '\n';
}
}
};
struct node {
vector<pair<int, info>> data;
node() {
data.emplace_back(0, info());
}
void add(int tim, info i) {
if (data.size() && data.back().first == tim)
data.back().second = i;
else
data.emplace_back(tim, i);
}
info& get(int tim) {
tim = max(tim, 0);
int lo = 0, hi = (int)data.size() - 1, mid;
while (lo < hi) {
mid = (lo + hi + 1) / 2;
if (data[mid].first <= tim) lo = mid;
else hi = mid - 1;
}
return data[lo].second;
}
};
struct segtree {
int n;
int tim;
vector<node> t;
vector<pair<int, int>> range;
segtree() {}
segtree(int sz) {
tim = 0;
n = max(2, sz);
while (n != (n & -n)) n += (n & -n);
t.resize(2 * n, node());
}
void advance_time(int newtim) {
tim = max(tim, newtim);
}
void fix(int x) {
t[x].add(tim, t[2 * x + 1].get(tim) * t[2 * x + 2].get(tim));
}
void upd(int x, int val) {
if (OO) cout << "upd " << x << " " << val << '\n';
x += n - 1;
t[x].add(tim, info(val, x - (n - 1)));
while (x) {
x = (x - 1) / 2;
fix(x);
}
}
int is_alive(int i, int T) {
info tmp = t[i + n - 1].get(T);
if (tmp.len[0][0] == 1 || tmp.len[1][1] == 1) return 1;
return 0;
}
info query(int l, int r, int T) {
if (l > r) return info();
return query(l, r, T, 0, 0, n - 1);
}
info query(int l, int r, int T, int node, int nl, int nr) {
if (nr < l || r < nl) return info();
if (l <= nl && nr <= r) return t[node].get(T);
int mid = (nl + nr) / 2;
return query(l, r, T, 2 * node + 1, nl, mid) * query(l, r, T, 2 * node + 2, mid + 1, nr);
}
};
struct sptable {
int n;
vector<int> a;
vector<int> mn, mx;
sptable() {}
sptable(const vector<int> &b) {
a = b;
n = max(2, (int)a.size());
while (n != (n & -n)) n += (n & -n);
mn.resize(2 * n);
mx.resize(2 * n);
for (int i = 0; i < a.size(); i++)
mn[i + n - 1] = mx[i + n - 1] = a[i];
for (int i = n - 2; i >= 0; i--)
mn[i] = min(mn[2 * i + 1], mn[2 * i + 2]), mx[i] = max(mx[2 * i + 1], mx[2 * i + 2]);
}
pair<int, int> query(int l, int r) {
if (l > r) return{ 1e9, -1e9 };
int mnres = 1e9, mxres = -1e9;
for (l += n - 1, r += n - 1; l < r; l = (l - 1) / 2, r = (r - 1) / 2) {
if (!(l & 1)) {
mnres = min(mnres, mn[l]);
mxres = max(mxres, mx[l]);
l++;
}
if (r & 1) {
mnres = min(mnres, mn[r]);
mxres = max(mxres, mx[r]);
r--;
}
}
if (l == r) {
mnres = min(mnres, mn[l]);
mxres = max(mxres, mx[l]);
}
return{ mnres, mxres };
}
};
struct superset {
int n;
vector<int> a;
set<int> ind;
set<pair<int, int>> q;
superset() {}
superset(const vector<int> &b) {
a = b;
n = a.size();
for (int i = 0; i < n; i++)
ind.insert(i);
for (int i = 0; i + 1 < n; i++)
q.emplace(abs(a[i] - a[i + 1]), i);
}
set<pair<int, int>>::iterator getq_element(set<int>::iterator it) {
// assuming it exists
return q.lower_bound(pair<int, int>(abs(a[*it] - a[*next(it)]), *it));
}
int upto(int R) {
auto it = ind.upper_bound(R);
if (it == ind.begin()) return -1;
return *prev(it);
}
int atleast(int L) {
auto it = ind.lower_bound(L);
if (it == ind.end()) return 1e9;
return *it;
}
// data kept between exchanges
int last_min;
set<int>::iterator last_i, last_j, last_k;
int size() {
return ind.size();
}
int get_min() {
return last_min = q.begin()->first;
}
void get_triple() {
auto p = *q.begin();
auto it = ind.lower_bound(p.second);
if (it == ind.begin())
last_i = it;
else
last_i = prev(it);
last_j = next(last_i);
last_k = next(last_j);
}
void remove(int &removed_index, int &i, int &j) {
int mx = max(max(a[*last_i], a[*last_j]), a[*last_k]);
int mn = min(min(a[*last_i], a[*last_j]), a[*last_k]);
int median = (ll)a[*last_i] + (ll)a[*last_j] + (ll)a[*last_k] - mn - mx;
set<int>::iterator it;
if (median == a[*last_i]) it = last_i;
else if (median == a[*last_j]) it = last_j;
else it = last_k;
removed_index = *it;
if (it == ind.begin()) i = -1;
else i = *prev(it);
if (next(it) == ind.end()) j = -1;
else j = *next(it);
// update q
if (i == -1) {
q.erase(getq_element(it));
}
else if (j == -1) {
q.erase(getq_element(prev(it)));
}
else {
q.erase(getq_element(prev(it)));
q.erase(getq_element(it));
q.insert(pair<int, int>(abs(a[i] - a[j]), i));
}
// update ind
ind.erase(it);
}
};
int n;
vector<int> h;
superset ind;
segtree T;
sptable table;
void init(int N, std::vector<int> H) {
n = N;
h = H;
ind = superset(h);
T = segtree(n);
table = sptable(h);
for (int i = 0; i + 1 < n; i++)
if (h[i] < h[i + 1])
T.upd(i, 0);
else
T.upd(i, 1);
while (ind.size() > 2) {
int d = ind.get_min();
T.advance_time(d);
ind.get_triple();
int index, li, ri;
ind.remove(index, li, ri);
T.upd(index, -1);
if (li != -1) {
if (ri == -1) {
T.upd(li, -1);
}
else {
if (h[li] < h[ri])
T.upd(li, 0);
else
T.upd(li, 1);
}
}
if (OO) {
cout << "at d = " << d << ", remove li ri " << index << " " << li << " " << ri << '\n';
}
}
}
int bruteforce(int l, int r, int d) {
int len = r - l + 1;
int best = 0;
for (int mask = 0; mask < (1 << len); mask++) {
vector<int> val;
for (int i = l; i <= r; i++) {
if (mask & (1 << (i - l)))
val.push_back(h[i]);
}
if (val.size() % 2 == 0) continue;
bool good = true;
for (int i = 0; i + 1 < val.size(); i++) {
if (i % 2 == 0 && val[i] + d > val[i + 1]) good = false;
if (i % 2 == 1 && val[i] - d < val[i + 1]) good = false;
}
if (good)
best = max(best, (int)val.size() / 2 + 1);
}
return best;
}
int max_towers(int L, int R, int D) {
int tim = D - 1;
// fix L, R
info q = T.query(L, R, tim);
int l = q.l;
int r = q.r;
if (OO) {
cout << "l r " << l << " " << r << '\n';
}
// break into cases - and also don't forget to consider the boundaries
if (r < l) {
// nothing in between - this is a monotonic range
return 1;
}
q = T.query(l, r - 1, tim);
if (OO) {
cout << "from query received:\n";
q.print();
}
if (L < l) {
// consider left boundary
info boundary = info();
auto pa = table.query(L, l - 1);
if (pa.first + D <= h[l])
boundary = info(0);
else if (pa.second - D >= h[l])
boundary = info(1);
q = boundary * q;
}
if (r < R) {
// consider right boundary
info boundary = info();
auto pa = table.query(r + 1, R);
if (h[r] - D >= pa.first)
boundary = info(1);
else if (h[r] + D <= pa.second)
boundary = info(0);
q = q * boundary;
}
return max(1, q.len[0][1] / 2 + 1);
}
Compilation message
towers.cpp: In constructor 'sptable::sptable(const std::vector<int>&)':
towers.cpp:119:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
119 | for (int i = 0; i < a.size(); i++)
| ~~^~~~~~~~~~
towers.cpp: In function 'int bruteforce(int, int, int)':
towers.cpp:281:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
281 | for (int i = 0; i + 1 < val.size(); i++) {
| ~~~~~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1018 ms |
59680 KB |
Output is correct |
2 |
Correct |
2089 ms |
102652 KB |
Output is correct |
3 |
Correct |
2080 ms |
102212 KB |
Output is correct |
4 |
Correct |
1970 ms |
103068 KB |
Output is correct |
5 |
Correct |
2033 ms |
103344 KB |
Output is correct |
6 |
Correct |
2237 ms |
103048 KB |
Output is correct |
7 |
Correct |
2217 ms |
103420 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
7 ms |
2000 KB |
Output is correct |
10 |
Correct |
8 ms |
1996 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
464 KB |
Output is correct |
2 |
Correct |
7 ms |
1616 KB |
Output is correct |
3 |
Correct |
7 ms |
1488 KB |
Output is correct |
4 |
Correct |
6 ms |
1360 KB |
Output is correct |
5 |
Correct |
6 ms |
1360 KB |
Output is correct |
6 |
Correct |
6 ms |
1472 KB |
Output is correct |
7 |
Correct |
7 ms |
1488 KB |
Output is correct |
8 |
Correct |
7 ms |
2000 KB |
Output is correct |
9 |
Correct |
7 ms |
2000 KB |
Output is correct |
10 |
Correct |
8 ms |
2112 KB |
Output is correct |
11 |
Correct |
7 ms |
2048 KB |
Output is correct |
12 |
Correct |
0 ms |
208 KB |
Output is correct |
13 |
Correct |
8 ms |
1996 KB |
Output is correct |
14 |
Correct |
7 ms |
2000 KB |
Output is correct |
15 |
Correct |
6 ms |
1488 KB |
Output is correct |
16 |
Correct |
6 ms |
1452 KB |
Output is correct |
17 |
Correct |
7 ms |
1484 KB |
Output is correct |
18 |
Correct |
9 ms |
2008 KB |
Output is correct |
19 |
Correct |
7 ms |
2000 KB |
Output is correct |
20 |
Correct |
7 ms |
1488 KB |
Output is correct |
21 |
Correct |
6 ms |
1360 KB |
Output is correct |
22 |
Correct |
6 ms |
1432 KB |
Output is correct |
23 |
Correct |
6 ms |
2000 KB |
Output is correct |
24 |
Correct |
7 ms |
2000 KB |
Output is correct |
25 |
Correct |
3 ms |
848 KB |
Output is correct |
26 |
Correct |
6 ms |
1616 KB |
Output is correct |
27 |
Correct |
7 ms |
1560 KB |
Output is correct |
28 |
Correct |
6 ms |
1488 KB |
Output is correct |
29 |
Correct |
7 ms |
1484 KB |
Output is correct |
30 |
Correct |
6 ms |
1360 KB |
Output is correct |
31 |
Correct |
6 ms |
1432 KB |
Output is correct |
32 |
Correct |
7 ms |
2000 KB |
Output is correct |
33 |
Correct |
8 ms |
2128 KB |
Output is correct |
34 |
Correct |
8 ms |
2000 KB |
Output is correct |
35 |
Correct |
7 ms |
2092 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
464 KB |
Output is correct |
2 |
Correct |
7 ms |
1616 KB |
Output is correct |
3 |
Correct |
7 ms |
1488 KB |
Output is correct |
4 |
Correct |
6 ms |
1360 KB |
Output is correct |
5 |
Correct |
6 ms |
1360 KB |
Output is correct |
6 |
Correct |
6 ms |
1472 KB |
Output is correct |
7 |
Correct |
7 ms |
1488 KB |
Output is correct |
8 |
Correct |
7 ms |
2000 KB |
Output is correct |
9 |
Correct |
7 ms |
2000 KB |
Output is correct |
10 |
Correct |
8 ms |
2112 KB |
Output is correct |
11 |
Correct |
7 ms |
2048 KB |
Output is correct |
12 |
Correct |
0 ms |
208 KB |
Output is correct |
13 |
Correct |
8 ms |
1996 KB |
Output is correct |
14 |
Correct |
7 ms |
2000 KB |
Output is correct |
15 |
Correct |
6 ms |
1488 KB |
Output is correct |
16 |
Correct |
6 ms |
1452 KB |
Output is correct |
17 |
Correct |
7 ms |
1484 KB |
Output is correct |
18 |
Correct |
9 ms |
2008 KB |
Output is correct |
19 |
Correct |
7 ms |
2000 KB |
Output is correct |
20 |
Correct |
7 ms |
1488 KB |
Output is correct |
21 |
Correct |
6 ms |
1360 KB |
Output is correct |
22 |
Correct |
6 ms |
1432 KB |
Output is correct |
23 |
Correct |
6 ms |
2000 KB |
Output is correct |
24 |
Correct |
7 ms |
2000 KB |
Output is correct |
25 |
Correct |
3 ms |
848 KB |
Output is correct |
26 |
Correct |
6 ms |
1616 KB |
Output is correct |
27 |
Correct |
7 ms |
1560 KB |
Output is correct |
28 |
Correct |
6 ms |
1488 KB |
Output is correct |
29 |
Correct |
7 ms |
1484 KB |
Output is correct |
30 |
Correct |
6 ms |
1360 KB |
Output is correct |
31 |
Correct |
6 ms |
1432 KB |
Output is correct |
32 |
Correct |
7 ms |
2000 KB |
Output is correct |
33 |
Correct |
8 ms |
2128 KB |
Output is correct |
34 |
Correct |
8 ms |
2000 KB |
Output is correct |
35 |
Correct |
7 ms |
2092 KB |
Output is correct |
36 |
Correct |
486 ms |
49188 KB |
Output is correct |
37 |
Correct |
869 ms |
82268 KB |
Output is correct |
38 |
Correct |
892 ms |
82340 KB |
Output is correct |
39 |
Correct |
826 ms |
74996 KB |
Output is correct |
40 |
Correct |
842 ms |
74888 KB |
Output is correct |
41 |
Correct |
807 ms |
74780 KB |
Output is correct |
42 |
Correct |
805 ms |
74840 KB |
Output is correct |
43 |
Correct |
1048 ms |
103224 KB |
Output is correct |
44 |
Correct |
1073 ms |
103380 KB |
Output is correct |
45 |
Correct |
1055 ms |
103132 KB |
Output is correct |
46 |
Correct |
988 ms |
103496 KB |
Output is correct |
47 |
Correct |
857 ms |
82364 KB |
Output is correct |
48 |
Correct |
773 ms |
75064 KB |
Output is correct |
49 |
Correct |
790 ms |
74928 KB |
Output is correct |
50 |
Correct |
982 ms |
103320 KB |
Output is correct |
51 |
Correct |
962 ms |
103524 KB |
Output is correct |
52 |
Correct |
872 ms |
82260 KB |
Output is correct |
53 |
Correct |
744 ms |
74940 KB |
Output is correct |
54 |
Correct |
768 ms |
74924 KB |
Output is correct |
55 |
Correct |
969 ms |
103136 KB |
Output is correct |
56 |
Correct |
948 ms |
103384 KB |
Output is correct |
57 |
Correct |
830 ms |
80108 KB |
Output is correct |
58 |
Correct |
853 ms |
82400 KB |
Output is correct |
59 |
Correct |
864 ms |
82192 KB |
Output is correct |
60 |
Correct |
733 ms |
75060 KB |
Output is correct |
61 |
Correct |
777 ms |
74960 KB |
Output is correct |
62 |
Correct |
748 ms |
74860 KB |
Output is correct |
63 |
Correct |
743 ms |
74992 KB |
Output is correct |
64 |
Correct |
929 ms |
103388 KB |
Output is correct |
65 |
Correct |
943 ms |
103764 KB |
Output is correct |
66 |
Correct |
993 ms |
103120 KB |
Output is correct |
67 |
Correct |
974 ms |
103924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1831 ms |
81956 KB |
Output is correct |
2 |
Correct |
2073 ms |
82176 KB |
Output is correct |
3 |
Correct |
2193 ms |
82372 KB |
Output is correct |
4 |
Correct |
1895 ms |
74924 KB |
Output is correct |
5 |
Correct |
1895 ms |
74768 KB |
Output is correct |
6 |
Correct |
1998 ms |
74956 KB |
Output is correct |
7 |
Correct |
2050 ms |
74716 KB |
Output is correct |
8 |
Correct |
2149 ms |
103576 KB |
Output is correct |
9 |
Correct |
2170 ms |
103696 KB |
Output is correct |
10 |
Correct |
2253 ms |
102804 KB |
Output is correct |
11 |
Correct |
2252 ms |
103452 KB |
Output is correct |
12 |
Correct |
2318 ms |
103084 KB |
Output is correct |
13 |
Correct |
2260 ms |
103360 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
7 ms |
2000 KB |
Output is correct |
16 |
Correct |
7 ms |
2000 KB |
Output is correct |
17 |
Correct |
895 ms |
82336 KB |
Output is correct |
18 |
Correct |
772 ms |
74980 KB |
Output is correct |
19 |
Correct |
723 ms |
74936 KB |
Output is correct |
20 |
Correct |
975 ms |
103492 KB |
Output is correct |
21 |
Correct |
935 ms |
103544 KB |
Output is correct |
22 |
Correct |
836 ms |
82304 KB |
Output is correct |
23 |
Correct |
754 ms |
74904 KB |
Output is correct |
24 |
Correct |
767 ms |
75004 KB |
Output is correct |
25 |
Correct |
955 ms |
103140 KB |
Output is correct |
26 |
Correct |
966 ms |
103336 KB |
Output is correct |
27 |
Correct |
6 ms |
1488 KB |
Output is correct |
28 |
Correct |
7 ms |
1464 KB |
Output is correct |
29 |
Correct |
6 ms |
1488 KB |
Output is correct |
30 |
Correct |
7 ms |
2000 KB |
Output is correct |
31 |
Correct |
6 ms |
2000 KB |
Output is correct |
32 |
Correct |
6 ms |
1616 KB |
Output is correct |
33 |
Correct |
6 ms |
1488 KB |
Output is correct |
34 |
Correct |
6 ms |
1360 KB |
Output is correct |
35 |
Correct |
8 ms |
2000 KB |
Output is correct |
36 |
Correct |
6 ms |
2000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
400 ms |
19004 KB |
Output is correct |
2 |
Correct |
1930 ms |
82236 KB |
Output is correct |
3 |
Correct |
1938 ms |
82184 KB |
Output is correct |
4 |
Correct |
1834 ms |
74864 KB |
Output is correct |
5 |
Correct |
1905 ms |
74948 KB |
Output is correct |
6 |
Correct |
1853 ms |
74992 KB |
Output is correct |
7 |
Correct |
1778 ms |
74980 KB |
Output is correct |
8 |
Correct |
1814 ms |
103236 KB |
Output is correct |
9 |
Correct |
1752 ms |
103040 KB |
Output is correct |
10 |
Correct |
1781 ms |
102992 KB |
Output is correct |
11 |
Correct |
1859 ms |
103392 KB |
Output is correct |
12 |
Correct |
819 ms |
82244 KB |
Output is correct |
13 |
Correct |
792 ms |
74848 KB |
Output is correct |
14 |
Correct |
781 ms |
74924 KB |
Output is correct |
15 |
Correct |
921 ms |
103148 KB |
Output is correct |
16 |
Correct |
959 ms |
103364 KB |
Output is correct |
17 |
Correct |
790 ms |
80168 KB |
Output is correct |
18 |
Correct |
825 ms |
82472 KB |
Output is correct |
19 |
Correct |
861 ms |
82252 KB |
Output is correct |
20 |
Correct |
733 ms |
74768 KB |
Output is correct |
21 |
Correct |
739 ms |
74864 KB |
Output is correct |
22 |
Correct |
723 ms |
74796 KB |
Output is correct |
23 |
Correct |
726 ms |
74992 KB |
Output is correct |
24 |
Correct |
932 ms |
103388 KB |
Output is correct |
25 |
Correct |
930 ms |
103624 KB |
Output is correct |
26 |
Correct |
942 ms |
103380 KB |
Output is correct |
27 |
Correct |
934 ms |
103812 KB |
Output is correct |
28 |
Correct |
9 ms |
1548 KB |
Output is correct |
29 |
Correct |
7 ms |
1360 KB |
Output is correct |
30 |
Correct |
7 ms |
1360 KB |
Output is correct |
31 |
Correct |
7 ms |
2000 KB |
Output is correct |
32 |
Correct |
7 ms |
2000 KB |
Output is correct |
33 |
Correct |
3 ms |
848 KB |
Output is correct |
34 |
Correct |
6 ms |
1616 KB |
Output is correct |
35 |
Correct |
6 ms |
1616 KB |
Output is correct |
36 |
Correct |
6 ms |
1500 KB |
Output is correct |
37 |
Correct |
6 ms |
1464 KB |
Output is correct |
38 |
Correct |
6 ms |
1360 KB |
Output is correct |
39 |
Correct |
6 ms |
1360 KB |
Output is correct |
40 |
Correct |
6 ms |
2000 KB |
Output is correct |
41 |
Correct |
9 ms |
2128 KB |
Output is correct |
42 |
Correct |
7 ms |
2028 KB |
Output is correct |
43 |
Correct |
6 ms |
2048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
464 KB |
Output is correct |
2 |
Correct |
7 ms |
1616 KB |
Output is correct |
3 |
Correct |
7 ms |
1488 KB |
Output is correct |
4 |
Correct |
6 ms |
1360 KB |
Output is correct |
5 |
Correct |
6 ms |
1360 KB |
Output is correct |
6 |
Correct |
6 ms |
1472 KB |
Output is correct |
7 |
Correct |
7 ms |
1488 KB |
Output is correct |
8 |
Correct |
7 ms |
2000 KB |
Output is correct |
9 |
Correct |
7 ms |
2000 KB |
Output is correct |
10 |
Correct |
8 ms |
2112 KB |
Output is correct |
11 |
Correct |
7 ms |
2048 KB |
Output is correct |
12 |
Correct |
0 ms |
208 KB |
Output is correct |
13 |
Correct |
8 ms |
1996 KB |
Output is correct |
14 |
Correct |
7 ms |
2000 KB |
Output is correct |
15 |
Correct |
6 ms |
1488 KB |
Output is correct |
16 |
Correct |
6 ms |
1452 KB |
Output is correct |
17 |
Correct |
7 ms |
1484 KB |
Output is correct |
18 |
Correct |
9 ms |
2008 KB |
Output is correct |
19 |
Correct |
7 ms |
2000 KB |
Output is correct |
20 |
Correct |
7 ms |
1488 KB |
Output is correct |
21 |
Correct |
6 ms |
1360 KB |
Output is correct |
22 |
Correct |
6 ms |
1432 KB |
Output is correct |
23 |
Correct |
6 ms |
2000 KB |
Output is correct |
24 |
Correct |
7 ms |
2000 KB |
Output is correct |
25 |
Correct |
3 ms |
848 KB |
Output is correct |
26 |
Correct |
6 ms |
1616 KB |
Output is correct |
27 |
Correct |
7 ms |
1560 KB |
Output is correct |
28 |
Correct |
6 ms |
1488 KB |
Output is correct |
29 |
Correct |
7 ms |
1484 KB |
Output is correct |
30 |
Correct |
6 ms |
1360 KB |
Output is correct |
31 |
Correct |
6 ms |
1432 KB |
Output is correct |
32 |
Correct |
7 ms |
2000 KB |
Output is correct |
33 |
Correct |
8 ms |
2128 KB |
Output is correct |
34 |
Correct |
8 ms |
2000 KB |
Output is correct |
35 |
Correct |
7 ms |
2092 KB |
Output is correct |
36 |
Correct |
486 ms |
49188 KB |
Output is correct |
37 |
Correct |
869 ms |
82268 KB |
Output is correct |
38 |
Correct |
892 ms |
82340 KB |
Output is correct |
39 |
Correct |
826 ms |
74996 KB |
Output is correct |
40 |
Correct |
842 ms |
74888 KB |
Output is correct |
41 |
Correct |
807 ms |
74780 KB |
Output is correct |
42 |
Correct |
805 ms |
74840 KB |
Output is correct |
43 |
Correct |
1048 ms |
103224 KB |
Output is correct |
44 |
Correct |
1073 ms |
103380 KB |
Output is correct |
45 |
Correct |
1055 ms |
103132 KB |
Output is correct |
46 |
Correct |
988 ms |
103496 KB |
Output is correct |
47 |
Correct |
857 ms |
82364 KB |
Output is correct |
48 |
Correct |
773 ms |
75064 KB |
Output is correct |
49 |
Correct |
790 ms |
74928 KB |
Output is correct |
50 |
Correct |
982 ms |
103320 KB |
Output is correct |
51 |
Correct |
962 ms |
103524 KB |
Output is correct |
52 |
Correct |
872 ms |
82260 KB |
Output is correct |
53 |
Correct |
744 ms |
74940 KB |
Output is correct |
54 |
Correct |
768 ms |
74924 KB |
Output is correct |
55 |
Correct |
969 ms |
103136 KB |
Output is correct |
56 |
Correct |
948 ms |
103384 KB |
Output is correct |
57 |
Correct |
830 ms |
80108 KB |
Output is correct |
58 |
Correct |
853 ms |
82400 KB |
Output is correct |
59 |
Correct |
864 ms |
82192 KB |
Output is correct |
60 |
Correct |
733 ms |
75060 KB |
Output is correct |
61 |
Correct |
777 ms |
74960 KB |
Output is correct |
62 |
Correct |
748 ms |
74860 KB |
Output is correct |
63 |
Correct |
743 ms |
74992 KB |
Output is correct |
64 |
Correct |
929 ms |
103388 KB |
Output is correct |
65 |
Correct |
943 ms |
103764 KB |
Output is correct |
66 |
Correct |
993 ms |
103120 KB |
Output is correct |
67 |
Correct |
974 ms |
103924 KB |
Output is correct |
68 |
Correct |
1831 ms |
81956 KB |
Output is correct |
69 |
Correct |
2073 ms |
82176 KB |
Output is correct |
70 |
Correct |
2193 ms |
82372 KB |
Output is correct |
71 |
Correct |
1895 ms |
74924 KB |
Output is correct |
72 |
Correct |
1895 ms |
74768 KB |
Output is correct |
73 |
Correct |
1998 ms |
74956 KB |
Output is correct |
74 |
Correct |
2050 ms |
74716 KB |
Output is correct |
75 |
Correct |
2149 ms |
103576 KB |
Output is correct |
76 |
Correct |
2170 ms |
103696 KB |
Output is correct |
77 |
Correct |
2253 ms |
102804 KB |
Output is correct |
78 |
Correct |
2252 ms |
103452 KB |
Output is correct |
79 |
Correct |
2318 ms |
103084 KB |
Output is correct |
80 |
Correct |
2260 ms |
103360 KB |
Output is correct |
81 |
Correct |
1 ms |
208 KB |
Output is correct |
82 |
Correct |
7 ms |
2000 KB |
Output is correct |
83 |
Correct |
7 ms |
2000 KB |
Output is correct |
84 |
Correct |
895 ms |
82336 KB |
Output is correct |
85 |
Correct |
772 ms |
74980 KB |
Output is correct |
86 |
Correct |
723 ms |
74936 KB |
Output is correct |
87 |
Correct |
975 ms |
103492 KB |
Output is correct |
88 |
Correct |
935 ms |
103544 KB |
Output is correct |
89 |
Correct |
836 ms |
82304 KB |
Output is correct |
90 |
Correct |
754 ms |
74904 KB |
Output is correct |
91 |
Correct |
767 ms |
75004 KB |
Output is correct |
92 |
Correct |
955 ms |
103140 KB |
Output is correct |
93 |
Correct |
966 ms |
103336 KB |
Output is correct |
94 |
Correct |
6 ms |
1488 KB |
Output is correct |
95 |
Correct |
7 ms |
1464 KB |
Output is correct |
96 |
Correct |
6 ms |
1488 KB |
Output is correct |
97 |
Correct |
7 ms |
2000 KB |
Output is correct |
98 |
Correct |
6 ms |
2000 KB |
Output is correct |
99 |
Correct |
6 ms |
1616 KB |
Output is correct |
100 |
Correct |
6 ms |
1488 KB |
Output is correct |
101 |
Correct |
6 ms |
1360 KB |
Output is correct |
102 |
Correct |
8 ms |
2000 KB |
Output is correct |
103 |
Correct |
6 ms |
2000 KB |
Output is correct |
104 |
Correct |
1918 ms |
75376 KB |
Output is correct |
105 |
Correct |
2266 ms |
82212 KB |
Output is correct |
106 |
Correct |
2192 ms |
82384 KB |
Output is correct |
107 |
Correct |
2059 ms |
74912 KB |
Output is correct |
108 |
Correct |
1973 ms |
75112 KB |
Output is correct |
109 |
Correct |
2019 ms |
74804 KB |
Output is correct |
110 |
Correct |
1948 ms |
74828 KB |
Output is correct |
111 |
Correct |
2134 ms |
102808 KB |
Output is correct |
112 |
Correct |
2058 ms |
103032 KB |
Output is correct |
113 |
Correct |
2138 ms |
103404 KB |
Output is correct |
114 |
Correct |
2013 ms |
103532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1018 ms |
59680 KB |
Output is correct |
2 |
Correct |
2089 ms |
102652 KB |
Output is correct |
3 |
Correct |
2080 ms |
102212 KB |
Output is correct |
4 |
Correct |
1970 ms |
103068 KB |
Output is correct |
5 |
Correct |
2033 ms |
103344 KB |
Output is correct |
6 |
Correct |
2237 ms |
103048 KB |
Output is correct |
7 |
Correct |
2217 ms |
103420 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
7 ms |
2000 KB |
Output is correct |
10 |
Correct |
8 ms |
1996 KB |
Output is correct |
11 |
Correct |
2 ms |
464 KB |
Output is correct |
12 |
Correct |
7 ms |
1616 KB |
Output is correct |
13 |
Correct |
7 ms |
1488 KB |
Output is correct |
14 |
Correct |
6 ms |
1360 KB |
Output is correct |
15 |
Correct |
6 ms |
1360 KB |
Output is correct |
16 |
Correct |
6 ms |
1472 KB |
Output is correct |
17 |
Correct |
7 ms |
1488 KB |
Output is correct |
18 |
Correct |
7 ms |
2000 KB |
Output is correct |
19 |
Correct |
7 ms |
2000 KB |
Output is correct |
20 |
Correct |
8 ms |
2112 KB |
Output is correct |
21 |
Correct |
7 ms |
2048 KB |
Output is correct |
22 |
Correct |
0 ms |
208 KB |
Output is correct |
23 |
Correct |
8 ms |
1996 KB |
Output is correct |
24 |
Correct |
7 ms |
2000 KB |
Output is correct |
25 |
Correct |
6 ms |
1488 KB |
Output is correct |
26 |
Correct |
6 ms |
1452 KB |
Output is correct |
27 |
Correct |
7 ms |
1484 KB |
Output is correct |
28 |
Correct |
9 ms |
2008 KB |
Output is correct |
29 |
Correct |
7 ms |
2000 KB |
Output is correct |
30 |
Correct |
7 ms |
1488 KB |
Output is correct |
31 |
Correct |
6 ms |
1360 KB |
Output is correct |
32 |
Correct |
6 ms |
1432 KB |
Output is correct |
33 |
Correct |
6 ms |
2000 KB |
Output is correct |
34 |
Correct |
7 ms |
2000 KB |
Output is correct |
35 |
Correct |
3 ms |
848 KB |
Output is correct |
36 |
Correct |
6 ms |
1616 KB |
Output is correct |
37 |
Correct |
7 ms |
1560 KB |
Output is correct |
38 |
Correct |
6 ms |
1488 KB |
Output is correct |
39 |
Correct |
7 ms |
1484 KB |
Output is correct |
40 |
Correct |
6 ms |
1360 KB |
Output is correct |
41 |
Correct |
6 ms |
1432 KB |
Output is correct |
42 |
Correct |
7 ms |
2000 KB |
Output is correct |
43 |
Correct |
8 ms |
2128 KB |
Output is correct |
44 |
Correct |
8 ms |
2000 KB |
Output is correct |
45 |
Correct |
7 ms |
2092 KB |
Output is correct |
46 |
Correct |
486 ms |
49188 KB |
Output is correct |
47 |
Correct |
869 ms |
82268 KB |
Output is correct |
48 |
Correct |
892 ms |
82340 KB |
Output is correct |
49 |
Correct |
826 ms |
74996 KB |
Output is correct |
50 |
Correct |
842 ms |
74888 KB |
Output is correct |
51 |
Correct |
807 ms |
74780 KB |
Output is correct |
52 |
Correct |
805 ms |
74840 KB |
Output is correct |
53 |
Correct |
1048 ms |
103224 KB |
Output is correct |
54 |
Correct |
1073 ms |
103380 KB |
Output is correct |
55 |
Correct |
1055 ms |
103132 KB |
Output is correct |
56 |
Correct |
988 ms |
103496 KB |
Output is correct |
57 |
Correct |
857 ms |
82364 KB |
Output is correct |
58 |
Correct |
773 ms |
75064 KB |
Output is correct |
59 |
Correct |
790 ms |
74928 KB |
Output is correct |
60 |
Correct |
982 ms |
103320 KB |
Output is correct |
61 |
Correct |
962 ms |
103524 KB |
Output is correct |
62 |
Correct |
872 ms |
82260 KB |
Output is correct |
63 |
Correct |
744 ms |
74940 KB |
Output is correct |
64 |
Correct |
768 ms |
74924 KB |
Output is correct |
65 |
Correct |
969 ms |
103136 KB |
Output is correct |
66 |
Correct |
948 ms |
103384 KB |
Output is correct |
67 |
Correct |
830 ms |
80108 KB |
Output is correct |
68 |
Correct |
853 ms |
82400 KB |
Output is correct |
69 |
Correct |
864 ms |
82192 KB |
Output is correct |
70 |
Correct |
733 ms |
75060 KB |
Output is correct |
71 |
Correct |
777 ms |
74960 KB |
Output is correct |
72 |
Correct |
748 ms |
74860 KB |
Output is correct |
73 |
Correct |
743 ms |
74992 KB |
Output is correct |
74 |
Correct |
929 ms |
103388 KB |
Output is correct |
75 |
Correct |
943 ms |
103764 KB |
Output is correct |
76 |
Correct |
993 ms |
103120 KB |
Output is correct |
77 |
Correct |
974 ms |
103924 KB |
Output is correct |
78 |
Correct |
1831 ms |
81956 KB |
Output is correct |
79 |
Correct |
2073 ms |
82176 KB |
Output is correct |
80 |
Correct |
2193 ms |
82372 KB |
Output is correct |
81 |
Correct |
1895 ms |
74924 KB |
Output is correct |
82 |
Correct |
1895 ms |
74768 KB |
Output is correct |
83 |
Correct |
1998 ms |
74956 KB |
Output is correct |
84 |
Correct |
2050 ms |
74716 KB |
Output is correct |
85 |
Correct |
2149 ms |
103576 KB |
Output is correct |
86 |
Correct |
2170 ms |
103696 KB |
Output is correct |
87 |
Correct |
2253 ms |
102804 KB |
Output is correct |
88 |
Correct |
2252 ms |
103452 KB |
Output is correct |
89 |
Correct |
2318 ms |
103084 KB |
Output is correct |
90 |
Correct |
2260 ms |
103360 KB |
Output is correct |
91 |
Correct |
1 ms |
208 KB |
Output is correct |
92 |
Correct |
7 ms |
2000 KB |
Output is correct |
93 |
Correct |
7 ms |
2000 KB |
Output is correct |
94 |
Correct |
895 ms |
82336 KB |
Output is correct |
95 |
Correct |
772 ms |
74980 KB |
Output is correct |
96 |
Correct |
723 ms |
74936 KB |
Output is correct |
97 |
Correct |
975 ms |
103492 KB |
Output is correct |
98 |
Correct |
935 ms |
103544 KB |
Output is correct |
99 |
Correct |
836 ms |
82304 KB |
Output is correct |
100 |
Correct |
754 ms |
74904 KB |
Output is correct |
101 |
Correct |
767 ms |
75004 KB |
Output is correct |
102 |
Correct |
955 ms |
103140 KB |
Output is correct |
103 |
Correct |
966 ms |
103336 KB |
Output is correct |
104 |
Correct |
6 ms |
1488 KB |
Output is correct |
105 |
Correct |
7 ms |
1464 KB |
Output is correct |
106 |
Correct |
6 ms |
1488 KB |
Output is correct |
107 |
Correct |
7 ms |
2000 KB |
Output is correct |
108 |
Correct |
6 ms |
2000 KB |
Output is correct |
109 |
Correct |
6 ms |
1616 KB |
Output is correct |
110 |
Correct |
6 ms |
1488 KB |
Output is correct |
111 |
Correct |
6 ms |
1360 KB |
Output is correct |
112 |
Correct |
8 ms |
2000 KB |
Output is correct |
113 |
Correct |
6 ms |
2000 KB |
Output is correct |
114 |
Correct |
400 ms |
19004 KB |
Output is correct |
115 |
Correct |
1930 ms |
82236 KB |
Output is correct |
116 |
Correct |
1938 ms |
82184 KB |
Output is correct |
117 |
Correct |
1834 ms |
74864 KB |
Output is correct |
118 |
Correct |
1905 ms |
74948 KB |
Output is correct |
119 |
Correct |
1853 ms |
74992 KB |
Output is correct |
120 |
Correct |
1778 ms |
74980 KB |
Output is correct |
121 |
Correct |
1814 ms |
103236 KB |
Output is correct |
122 |
Correct |
1752 ms |
103040 KB |
Output is correct |
123 |
Correct |
1781 ms |
102992 KB |
Output is correct |
124 |
Correct |
1859 ms |
103392 KB |
Output is correct |
125 |
Correct |
819 ms |
82244 KB |
Output is correct |
126 |
Correct |
792 ms |
74848 KB |
Output is correct |
127 |
Correct |
781 ms |
74924 KB |
Output is correct |
128 |
Correct |
921 ms |
103148 KB |
Output is correct |
129 |
Correct |
959 ms |
103364 KB |
Output is correct |
130 |
Correct |
790 ms |
80168 KB |
Output is correct |
131 |
Correct |
825 ms |
82472 KB |
Output is correct |
132 |
Correct |
861 ms |
82252 KB |
Output is correct |
133 |
Correct |
733 ms |
74768 KB |
Output is correct |
134 |
Correct |
739 ms |
74864 KB |
Output is correct |
135 |
Correct |
723 ms |
74796 KB |
Output is correct |
136 |
Correct |
726 ms |
74992 KB |
Output is correct |
137 |
Correct |
932 ms |
103388 KB |
Output is correct |
138 |
Correct |
930 ms |
103624 KB |
Output is correct |
139 |
Correct |
942 ms |
103380 KB |
Output is correct |
140 |
Correct |
934 ms |
103812 KB |
Output is correct |
141 |
Correct |
9 ms |
1548 KB |
Output is correct |
142 |
Correct |
7 ms |
1360 KB |
Output is correct |
143 |
Correct |
7 ms |
1360 KB |
Output is correct |
144 |
Correct |
7 ms |
2000 KB |
Output is correct |
145 |
Correct |
7 ms |
2000 KB |
Output is correct |
146 |
Correct |
3 ms |
848 KB |
Output is correct |
147 |
Correct |
6 ms |
1616 KB |
Output is correct |
148 |
Correct |
6 ms |
1616 KB |
Output is correct |
149 |
Correct |
6 ms |
1500 KB |
Output is correct |
150 |
Correct |
6 ms |
1464 KB |
Output is correct |
151 |
Correct |
6 ms |
1360 KB |
Output is correct |
152 |
Correct |
6 ms |
1360 KB |
Output is correct |
153 |
Correct |
6 ms |
2000 KB |
Output is correct |
154 |
Correct |
9 ms |
2128 KB |
Output is correct |
155 |
Correct |
7 ms |
2028 KB |
Output is correct |
156 |
Correct |
6 ms |
2048 KB |
Output is correct |
157 |
Correct |
1918 ms |
75376 KB |
Output is correct |
158 |
Correct |
2266 ms |
82212 KB |
Output is correct |
159 |
Correct |
2192 ms |
82384 KB |
Output is correct |
160 |
Correct |
2059 ms |
74912 KB |
Output is correct |
161 |
Correct |
1973 ms |
75112 KB |
Output is correct |
162 |
Correct |
2019 ms |
74804 KB |
Output is correct |
163 |
Correct |
1948 ms |
74828 KB |
Output is correct |
164 |
Correct |
2134 ms |
102808 KB |
Output is correct |
165 |
Correct |
2058 ms |
103032 KB |
Output is correct |
166 |
Correct |
2138 ms |
103404 KB |
Output is correct |
167 |
Correct |
2013 ms |
103532 KB |
Output is correct |
168 |
Correct |
0 ms |
208 KB |
Output is correct |
169 |
Correct |
1072 ms |
31036 KB |
Output is correct |
170 |
Correct |
2175 ms |
82244 KB |
Output is correct |
171 |
Correct |
2317 ms |
82444 KB |
Output is correct |
172 |
Correct |
2231 ms |
74888 KB |
Output is correct |
173 |
Correct |
1971 ms |
74828 KB |
Output is correct |
174 |
Correct |
2073 ms |
75048 KB |
Output is correct |
175 |
Correct |
2088 ms |
74864 KB |
Output is correct |
176 |
Correct |
1920 ms |
103112 KB |
Output is correct |
177 |
Correct |
2190 ms |
103196 KB |
Output is correct |
178 |
Correct |
2152 ms |
103164 KB |
Output is correct |
179 |
Correct |
2174 ms |
103620 KB |
Output is correct |