/*
author: Maksim1744
created: 24.04.2024 03:13:57
*/
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sum(a) ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a) (*min_element((a).begin(), (a).end()))
#define maxe(a) (*max_element((a).begin(), (a).end()))
#define mini(a) ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a) ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
template<typename T> vector<T>& operator-- (vector<T> &v){for (auto& i : v) --i; return v;}
template<typename T> vector<T>& operator++ (vector<T> &v){for (auto& i : v) ++i; return v;}
template<typename T> istream& operator>>(istream& is, vector<T> &v){for (auto& i : v) is >> i; return is;}
template<typename T> ostream& operator<<(ostream& os, vector<T> v){for (auto& i : v) os << i << ' '; return os;}
template<typename T, typename U> pair<T,U>& operator-- (pair<T, U> &p){--p.first; --p.second; return p;}
template<typename T, typename U> pair<T,U>& operator++ (pair<T, U> &p){++p.first; ++p.second; return p;}
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U> &p){is >> p.first >> p.second; return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, pair<T, U> p){os << p.first << ' ' << p.second; return os;}
template<typename T, typename U> pair<T,U> operator-(pair<T,U> a, pair<T,U> b){return mp(a.first-b.first, a.second-b.second);}
template<typename T, typename U> pair<T,U> operator+(pair<T,U> a, pair<T,U> b){return mp(a.first+b.first, a.second+b.second);}
template<typename T, typename U> void umin(T& a, U b){if (a > b) a = b;}
template<typename T, typename U> void umax(T& a, U b){if (a < b) a = b;}
#ifdef HOME
#define SHOW_COLORS
#include "/mnt/c/Libs/tools/print.cpp"
#else
#define show(...) void(0)
#define debugf(fun) fun
#define debugv(var) var
#define mclock void(0)
#define shows void(0)
#define debug if (false)
#define OSTREAM(...) ;
#define OSTREAM0(...) ;
#endif
template<typename T, typename F = std::function<T(const T&, const T&)>>
struct SparseTable {
vector<vector<T>> table;
vector<int> p2;
F combine;
SparseTable(int n, F combine) : combine(combine) {
while ((1 << table.size()) <= n || table.empty())
table.emplace_back(n);
}
template<typename U>
SparseTable(const vector<U>& v, F combine) : SparseTable<T>(v.size(), combine) {
table[0].assign(v.begin(), v.end());
build();
}
void build() {
p2.resize(table[0].size() + 1);
for (int i = 2; i < p2.size(); ++i)
p2[i] = p2[i / 2] + 1;
for (int i = 1; i < table.size(); ++i) {
for (int j = 0; j + (1 << i) <= table[i].size(); ++j) {
table[i][j] = combine(table[i - 1][j], table[i - 1][j + (1 << (i - 1))]);
}
}
}
T ask(int l, int r) {
int ln = p2[r - l + 1];
if (r - l + 1 == ln) return table[ln][l];
return combine(table[ln][l], table[ln][r - (1 << ln) + 1]);
}
};
const int inf = 2e9;
int n;
vector<int> h;
SparseTable<int> sparse_min(1, [](int a, int b) { return min(a, b); });
SparseTable<int> sparse_max(1, [](int a, int b) { return max(a, b); });
vector<int> hill, valley;
struct Data {
int len = 0;
int left = -1;
int last_new = -1;
Data() {}
Data(int x, int ind) {
left = x;
len = 0;
if (left != -1) {
last_new = ind;
len = 1;
}
}
int right() const {
return len % 2 == 1 ? left : 1 - left;
}
void update(const Data& l, const Data& r) {
if (l.len == 0) {
len = r.len;
left = r.left;
last_new = r.last_new;
} else if (r.len == 0) {
len = l.len;
left = l.left;
last_new = l.last_new;
} else {
len = l.len + r.len - (l.right() == r.left);
if (r.len == 1 && r.left == l.right()) {
last_new = l.last_new;
} else {
last_new = r.last_new;
}
left = l.left;
assert(right() == r.right());
}
}
};
struct Node {
Node* l = nullptr;
Node* r = nullptr;
Data data;
Node() {}
Node(int x, int ind) : data(x, ind) {}
void update() {
assert(l != nullptr);
assert(r != nullptr);
data.update(l->data, r->data);
}
};
OSTREAM(Node, len, left, last_new);
Node* build(int l, int r, const vector<int>& v) {
if (l == r) {
return new Node(v[l], l);
}
int m = (l + r) / 2;
auto node = new Node();
node->l = build(l, m, v);
node->r = build(m + 1, r, v);
node->update();
return node;
}
Node* update(Node* node, int i, int val, int vl, int vr) {
if (vl == vr) {
return new Node(val, i);
}
auto root = new Node();
root->l = node->l;
root->r = node->r;
int m = (vl + vr) / 2;
if (i <= m) {
root->l = update(node->l, i, val, vl, m);
} else {
root->r = update(node->r, i, val, m + 1, vr);
}
root->update();
return root;
}
Data ask(Node* node, int l, int r, int vl, int vr) {
if (l <= vl && vr <= r) {
return node->data;
}
if (vr < l || vl > r) {
return Data(-1, -1);
}
int m = (vl + vr) / 2;
Data n;
auto dl = ask(node->l, l, r, vl, m);
auto dr = ask(node->r, l, r, m + 1, vr);
n.update(dl, dr);
return n;
}
vector<Node*> roots;
vector<int> ds;
void init(int n_, std::vector<int> h_) {
n = n_;
h = h_;
h.pb(inf);
n = h.size();
roots.clear();
ds.clear();
sparse_min = SparseTable<int>(h, [](int a, int b) { return min(a, b); });
sparse_max = SparseTable<int>(h, [](int a, int b) { return max(a, b); });
hill.assign(n, -1);
valley.assign(n, -1);
vector<int> stup, stdown;
for (int i = n - 1; i >= 0; --i) {
while (!stup.empty() && h[stup.back()] < h[i])
stup.pop_back();
while (!stdown.empty() && h[stdown.back()] > h[i])
stdown.pop_back();
if (stup.empty()) {
hill[i] = inf;
} else {
hill[i] = h[i] - sparse_min.ask(i, stup.back());
}
if (stdown.empty()) {
valley[i] = inf;
} else {
valley[i] = -h[i] + sparse_max.ask(i, stdown.back());
}
stup.push_back(i);
stdown.push_back(i);
}
vector<pair<int, int>> events;
for (int i = 0; i < n; ++i) {
if (hill[i] > 0) events.eb(hill[i], i);
if (valley[i] > 0) events.eb(valley[i], i);
}
show(hill);
show(valley);
show(events);
sort(events.begin(), events.end());
reverse(events.begin(), events.end());
ds.pb(inf + 1);
roots.pb(build(0, n-1, vector<int>(n, -1)));
int ind = 0;
while (ind < events.size()) {
shows;
int r = ind;
Node* next = roots.back();
ds.pb(events[ind].first);
show(ds.back());
while (r < events.size() && events[r].first == events[ind].first) {
int i = events[r].second;
int val = (ds.back() <= hill[i] ? 1 : (ds.back() <= valley[i] ? 0 : -1));
show(i, val);
next = update(next, i, val, 0, n-1);
++r;
}
roots.pb(next);
ind = r;
}
}
int max_towers(int l, int r, int d) {
if (l == r) return 1;
int L = -1, R = ds.size();
while (R - L > 1) {
int C = (L + R) / 2;
if (ds[C] >= d)
L = C;
else
R = C;
}
show(ds);
show(L);
auto res = ask(roots[L], l, r-1, 0, n-1);
int ans = 0;
if (res.len > 0) {
ans = res.len;
if (res.left == 1) {
--ans;
}
int last = res.last_new;
if (ans % 2 == 0 && ans > 0 && sparse_min.ask(last + 1, r) <= h[last] - d)
++ans;
}
return max(1, (ans + 1) / 2);
}
#ifdef HOUSE
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
int n, q;
cin >> n >> q;
vector<int> h(n);
cin >> h;
init(n, h);
while (q--) {
int l, r, d;
cin >> l >> r >> d;
cout << max_towers(l, r, d) << '\n';
}
return 0;
}
#endif
Compilation message
towers.cpp: In function 'void init(int, std::vector<int>)':
towers.cpp:250:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
250 | while (ind < events.size()) {
| ~~~~^~~~~~~~~~~~~~~
towers.cpp:256:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
256 | while (r < events.size() && events[r].first == events[ind].first) {
| ~~^~~~~~~~~~~~~~~
towers.cpp: In instantiation of 'void SparseTable<T, F>::build() [with T = int; F = std::function<int(const int&, const int&)>]':
towers.cpp:65:9: required from 'SparseTable<T, F>::SparseTable(const std::vector<U>&, F) [with U = int; T = int; F = std::function<int(const int&, const int&)>]'
towers.cpp:209:76: required from here
towers.cpp:70:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
70 | for (int i = 2; i < p2.size(); ++i)
| ~~^~~~~~~~~~~
towers.cpp:72:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int>, std::allocator<std::vector<int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
72 | for (int i = 1; i < table.size(); ++i) {
| ~~^~~~~~~~~~~~~~
towers.cpp:73:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
73 | for (int j = 0; j + (1 << i) <= table[i].size(); ++j) {
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
380 ms |
63840 KB |
Output is correct |
2 |
Correct |
830 ms |
111256 KB |
Output is correct |
3 |
Correct |
839 ms |
111216 KB |
Output is correct |
4 |
Correct |
805 ms |
110084 KB |
Output is correct |
5 |
Correct |
829 ms |
111260 KB |
Output is correct |
6 |
Correct |
779 ms |
111260 KB |
Output is correct |
7 |
Correct |
771 ms |
111232 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
2 ms |
1880 KB |
Output is correct |
10 |
Correct |
2 ms |
1880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
2 ms |
1880 KB |
Output is correct |
3 |
Correct |
2 ms |
1880 KB |
Output is correct |
4 |
Correct |
2 ms |
1880 KB |
Output is correct |
5 |
Correct |
2 ms |
1880 KB |
Output is correct |
6 |
Correct |
2 ms |
1880 KB |
Output is correct |
7 |
Correct |
2 ms |
1948 KB |
Output is correct |
8 |
Correct |
3 ms |
1880 KB |
Output is correct |
9 |
Correct |
2 ms |
1880 KB |
Output is correct |
10 |
Correct |
2 ms |
1880 KB |
Output is correct |
11 |
Correct |
2 ms |
1880 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
2 ms |
1880 KB |
Output is correct |
14 |
Correct |
2 ms |
1880 KB |
Output is correct |
15 |
Correct |
2 ms |
1880 KB |
Output is correct |
16 |
Correct |
2 ms |
1888 KB |
Output is correct |
17 |
Correct |
2 ms |
2132 KB |
Output is correct |
18 |
Correct |
2 ms |
1880 KB |
Output is correct |
19 |
Correct |
2 ms |
1880 KB |
Output is correct |
20 |
Correct |
2 ms |
1880 KB |
Output is correct |
21 |
Correct |
2 ms |
2132 KB |
Output is correct |
22 |
Correct |
2 ms |
1880 KB |
Output is correct |
23 |
Correct |
2 ms |
1880 KB |
Output is correct |
24 |
Correct |
2 ms |
1880 KB |
Output is correct |
25 |
Correct |
1 ms |
856 KB |
Output is correct |
26 |
Correct |
2 ms |
1880 KB |
Output is correct |
27 |
Correct |
2 ms |
1880 KB |
Output is correct |
28 |
Correct |
2 ms |
1880 KB |
Output is correct |
29 |
Correct |
2 ms |
1880 KB |
Output is correct |
30 |
Correct |
2 ms |
1880 KB |
Output is correct |
31 |
Correct |
3 ms |
1880 KB |
Output is correct |
32 |
Correct |
2 ms |
1888 KB |
Output is correct |
33 |
Correct |
2 ms |
1880 KB |
Output is correct |
34 |
Correct |
2 ms |
1880 KB |
Output is correct |
35 |
Correct |
2 ms |
1880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
2 ms |
1880 KB |
Output is correct |
3 |
Correct |
2 ms |
1880 KB |
Output is correct |
4 |
Correct |
2 ms |
1880 KB |
Output is correct |
5 |
Correct |
2 ms |
1880 KB |
Output is correct |
6 |
Correct |
2 ms |
1880 KB |
Output is correct |
7 |
Correct |
2 ms |
1948 KB |
Output is correct |
8 |
Correct |
3 ms |
1880 KB |
Output is correct |
9 |
Correct |
2 ms |
1880 KB |
Output is correct |
10 |
Correct |
2 ms |
1880 KB |
Output is correct |
11 |
Correct |
2 ms |
1880 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
2 ms |
1880 KB |
Output is correct |
14 |
Correct |
2 ms |
1880 KB |
Output is correct |
15 |
Correct |
2 ms |
1880 KB |
Output is correct |
16 |
Correct |
2 ms |
1888 KB |
Output is correct |
17 |
Correct |
2 ms |
2132 KB |
Output is correct |
18 |
Correct |
2 ms |
1880 KB |
Output is correct |
19 |
Correct |
2 ms |
1880 KB |
Output is correct |
20 |
Correct |
2 ms |
1880 KB |
Output is correct |
21 |
Correct |
2 ms |
2132 KB |
Output is correct |
22 |
Correct |
2 ms |
1880 KB |
Output is correct |
23 |
Correct |
2 ms |
1880 KB |
Output is correct |
24 |
Correct |
2 ms |
1880 KB |
Output is correct |
25 |
Correct |
1 ms |
856 KB |
Output is correct |
26 |
Correct |
2 ms |
1880 KB |
Output is correct |
27 |
Correct |
2 ms |
1880 KB |
Output is correct |
28 |
Correct |
2 ms |
1880 KB |
Output is correct |
29 |
Correct |
2 ms |
1880 KB |
Output is correct |
30 |
Correct |
2 ms |
1880 KB |
Output is correct |
31 |
Correct |
3 ms |
1880 KB |
Output is correct |
32 |
Correct |
2 ms |
1888 KB |
Output is correct |
33 |
Correct |
2 ms |
1880 KB |
Output is correct |
34 |
Correct |
2 ms |
1880 KB |
Output is correct |
35 |
Correct |
2 ms |
1880 KB |
Output is correct |
36 |
Correct |
101 ms |
69812 KB |
Output is correct |
37 |
Correct |
158 ms |
110812 KB |
Output is correct |
38 |
Correct |
158 ms |
110688 KB |
Output is correct |
39 |
Correct |
157 ms |
110752 KB |
Output is correct |
40 |
Correct |
159 ms |
110784 KB |
Output is correct |
41 |
Correct |
156 ms |
110784 KB |
Output is correct |
42 |
Correct |
161 ms |
110832 KB |
Output is correct |
43 |
Correct |
114 ms |
110084 KB |
Output is correct |
44 |
Correct |
111 ms |
111300 KB |
Output is correct |
45 |
Correct |
109 ms |
110392 KB |
Output is correct |
46 |
Correct |
111 ms |
111008 KB |
Output is correct |
47 |
Correct |
155 ms |
110676 KB |
Output is correct |
48 |
Correct |
160 ms |
110920 KB |
Output is correct |
49 |
Correct |
160 ms |
110792 KB |
Output is correct |
50 |
Correct |
110 ms |
111268 KB |
Output is correct |
51 |
Correct |
112 ms |
109996 KB |
Output is correct |
52 |
Correct |
156 ms |
110748 KB |
Output is correct |
53 |
Correct |
170 ms |
110804 KB |
Output is correct |
54 |
Correct |
155 ms |
110832 KB |
Output is correct |
55 |
Correct |
110 ms |
111280 KB |
Output is correct |
56 |
Correct |
108 ms |
110636 KB |
Output is correct |
57 |
Correct |
159 ms |
106812 KB |
Output is correct |
58 |
Correct |
163 ms |
110736 KB |
Output is correct |
59 |
Correct |
162 ms |
110748 KB |
Output is correct |
60 |
Correct |
155 ms |
110712 KB |
Output is correct |
61 |
Correct |
186 ms |
110748 KB |
Output is correct |
62 |
Correct |
158 ms |
110744 KB |
Output is correct |
63 |
Correct |
156 ms |
110788 KB |
Output is correct |
64 |
Correct |
117 ms |
109976 KB |
Output is correct |
65 |
Correct |
113 ms |
111296 KB |
Output is correct |
66 |
Correct |
145 ms |
110924 KB |
Output is correct |
67 |
Correct |
117 ms |
111276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
681 ms |
109980 KB |
Output is correct |
2 |
Correct |
875 ms |
110728 KB |
Output is correct |
3 |
Correct |
905 ms |
110892 KB |
Output is correct |
4 |
Correct |
866 ms |
110860 KB |
Output is correct |
5 |
Correct |
894 ms |
110748 KB |
Output is correct |
6 |
Correct |
840 ms |
110892 KB |
Output is correct |
7 |
Correct |
828 ms |
110744 KB |
Output is correct |
8 |
Correct |
749 ms |
109980 KB |
Output is correct |
9 |
Correct |
788 ms |
111264 KB |
Output is correct |
10 |
Correct |
803 ms |
110296 KB |
Output is correct |
11 |
Correct |
809 ms |
111160 KB |
Output is correct |
12 |
Correct |
804 ms |
111212 KB |
Output is correct |
13 |
Correct |
772 ms |
111096 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
2 ms |
1880 KB |
Output is correct |
16 |
Correct |
3 ms |
1880 KB |
Output is correct |
17 |
Correct |
178 ms |
110796 KB |
Output is correct |
18 |
Correct |
164 ms |
110920 KB |
Output is correct |
19 |
Correct |
167 ms |
110768 KB |
Output is correct |
20 |
Correct |
124 ms |
111104 KB |
Output is correct |
21 |
Correct |
112 ms |
110024 KB |
Output is correct |
22 |
Correct |
184 ms |
110776 KB |
Output is correct |
23 |
Correct |
159 ms |
110744 KB |
Output is correct |
24 |
Correct |
166 ms |
110672 KB |
Output is correct |
25 |
Correct |
117 ms |
111212 KB |
Output is correct |
26 |
Correct |
121 ms |
110628 KB |
Output is correct |
27 |
Correct |
2 ms |
1880 KB |
Output is correct |
28 |
Correct |
2 ms |
1880 KB |
Output is correct |
29 |
Correct |
2 ms |
2132 KB |
Output is correct |
30 |
Correct |
2 ms |
1880 KB |
Output is correct |
31 |
Correct |
3 ms |
1880 KB |
Output is correct |
32 |
Correct |
2 ms |
1880 KB |
Output is correct |
33 |
Correct |
2 ms |
1880 KB |
Output is correct |
34 |
Correct |
3 ms |
1880 KB |
Output is correct |
35 |
Correct |
2 ms |
1880 KB |
Output is correct |
36 |
Correct |
2 ms |
1880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
224 ms |
24108 KB |
Output is correct |
2 |
Correct |
892 ms |
110912 KB |
Output is correct |
3 |
Correct |
854 ms |
110896 KB |
Output is correct |
4 |
Correct |
837 ms |
110748 KB |
Output is correct |
5 |
Correct |
858 ms |
110868 KB |
Output is correct |
6 |
Correct |
854 ms |
110908 KB |
Output is correct |
7 |
Correct |
818 ms |
110752 KB |
Output is correct |
8 |
Correct |
706 ms |
109980 KB |
Output is correct |
9 |
Correct |
715 ms |
111168 KB |
Output is correct |
10 |
Correct |
694 ms |
110748 KB |
Output is correct |
11 |
Correct |
730 ms |
111028 KB |
Output is correct |
12 |
Correct |
168 ms |
110912 KB |
Output is correct |
13 |
Correct |
157 ms |
110788 KB |
Output is correct |
14 |
Correct |
157 ms |
110756 KB |
Output is correct |
15 |
Correct |
111 ms |
111268 KB |
Output is correct |
16 |
Correct |
108 ms |
110616 KB |
Output is correct |
17 |
Correct |
154 ms |
106808 KB |
Output is correct |
18 |
Correct |
161 ms |
110868 KB |
Output is correct |
19 |
Correct |
167 ms |
110956 KB |
Output is correct |
20 |
Correct |
158 ms |
111000 KB |
Output is correct |
21 |
Correct |
156 ms |
110764 KB |
Output is correct |
22 |
Correct |
162 ms |
111188 KB |
Output is correct |
23 |
Correct |
156 ms |
110880 KB |
Output is correct |
24 |
Correct |
111 ms |
110000 KB |
Output is correct |
25 |
Correct |
112 ms |
111272 KB |
Output is correct |
26 |
Correct |
114 ms |
110748 KB |
Output is correct |
27 |
Correct |
111 ms |
111260 KB |
Output is correct |
28 |
Correct |
2 ms |
1880 KB |
Output is correct |
29 |
Correct |
2 ms |
1880 KB |
Output is correct |
30 |
Correct |
2 ms |
1880 KB |
Output is correct |
31 |
Correct |
2 ms |
1880 KB |
Output is correct |
32 |
Correct |
2 ms |
1880 KB |
Output is correct |
33 |
Correct |
1 ms |
856 KB |
Output is correct |
34 |
Correct |
2 ms |
1880 KB |
Output is correct |
35 |
Correct |
2 ms |
1880 KB |
Output is correct |
36 |
Correct |
2 ms |
1880 KB |
Output is correct |
37 |
Correct |
2 ms |
1880 KB |
Output is correct |
38 |
Correct |
2 ms |
1880 KB |
Output is correct |
39 |
Correct |
2 ms |
1880 KB |
Output is correct |
40 |
Correct |
2 ms |
1880 KB |
Output is correct |
41 |
Correct |
2 ms |
1880 KB |
Output is correct |
42 |
Correct |
2 ms |
1880 KB |
Output is correct |
43 |
Correct |
2 ms |
1880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
2 ms |
1880 KB |
Output is correct |
3 |
Correct |
2 ms |
1880 KB |
Output is correct |
4 |
Correct |
2 ms |
1880 KB |
Output is correct |
5 |
Correct |
2 ms |
1880 KB |
Output is correct |
6 |
Correct |
2 ms |
1880 KB |
Output is correct |
7 |
Correct |
2 ms |
1948 KB |
Output is correct |
8 |
Correct |
3 ms |
1880 KB |
Output is correct |
9 |
Correct |
2 ms |
1880 KB |
Output is correct |
10 |
Correct |
2 ms |
1880 KB |
Output is correct |
11 |
Correct |
2 ms |
1880 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
2 ms |
1880 KB |
Output is correct |
14 |
Correct |
2 ms |
1880 KB |
Output is correct |
15 |
Correct |
2 ms |
1880 KB |
Output is correct |
16 |
Correct |
2 ms |
1888 KB |
Output is correct |
17 |
Correct |
2 ms |
2132 KB |
Output is correct |
18 |
Correct |
2 ms |
1880 KB |
Output is correct |
19 |
Correct |
2 ms |
1880 KB |
Output is correct |
20 |
Correct |
2 ms |
1880 KB |
Output is correct |
21 |
Correct |
2 ms |
2132 KB |
Output is correct |
22 |
Correct |
2 ms |
1880 KB |
Output is correct |
23 |
Correct |
2 ms |
1880 KB |
Output is correct |
24 |
Correct |
2 ms |
1880 KB |
Output is correct |
25 |
Correct |
1 ms |
856 KB |
Output is correct |
26 |
Correct |
2 ms |
1880 KB |
Output is correct |
27 |
Correct |
2 ms |
1880 KB |
Output is correct |
28 |
Correct |
2 ms |
1880 KB |
Output is correct |
29 |
Correct |
2 ms |
1880 KB |
Output is correct |
30 |
Correct |
2 ms |
1880 KB |
Output is correct |
31 |
Correct |
3 ms |
1880 KB |
Output is correct |
32 |
Correct |
2 ms |
1888 KB |
Output is correct |
33 |
Correct |
2 ms |
1880 KB |
Output is correct |
34 |
Correct |
2 ms |
1880 KB |
Output is correct |
35 |
Correct |
2 ms |
1880 KB |
Output is correct |
36 |
Correct |
101 ms |
69812 KB |
Output is correct |
37 |
Correct |
158 ms |
110812 KB |
Output is correct |
38 |
Correct |
158 ms |
110688 KB |
Output is correct |
39 |
Correct |
157 ms |
110752 KB |
Output is correct |
40 |
Correct |
159 ms |
110784 KB |
Output is correct |
41 |
Correct |
156 ms |
110784 KB |
Output is correct |
42 |
Correct |
161 ms |
110832 KB |
Output is correct |
43 |
Correct |
114 ms |
110084 KB |
Output is correct |
44 |
Correct |
111 ms |
111300 KB |
Output is correct |
45 |
Correct |
109 ms |
110392 KB |
Output is correct |
46 |
Correct |
111 ms |
111008 KB |
Output is correct |
47 |
Correct |
155 ms |
110676 KB |
Output is correct |
48 |
Correct |
160 ms |
110920 KB |
Output is correct |
49 |
Correct |
160 ms |
110792 KB |
Output is correct |
50 |
Correct |
110 ms |
111268 KB |
Output is correct |
51 |
Correct |
112 ms |
109996 KB |
Output is correct |
52 |
Correct |
156 ms |
110748 KB |
Output is correct |
53 |
Correct |
170 ms |
110804 KB |
Output is correct |
54 |
Correct |
155 ms |
110832 KB |
Output is correct |
55 |
Correct |
110 ms |
111280 KB |
Output is correct |
56 |
Correct |
108 ms |
110636 KB |
Output is correct |
57 |
Correct |
159 ms |
106812 KB |
Output is correct |
58 |
Correct |
163 ms |
110736 KB |
Output is correct |
59 |
Correct |
162 ms |
110748 KB |
Output is correct |
60 |
Correct |
155 ms |
110712 KB |
Output is correct |
61 |
Correct |
186 ms |
110748 KB |
Output is correct |
62 |
Correct |
158 ms |
110744 KB |
Output is correct |
63 |
Correct |
156 ms |
110788 KB |
Output is correct |
64 |
Correct |
117 ms |
109976 KB |
Output is correct |
65 |
Correct |
113 ms |
111296 KB |
Output is correct |
66 |
Correct |
145 ms |
110924 KB |
Output is correct |
67 |
Correct |
117 ms |
111276 KB |
Output is correct |
68 |
Correct |
681 ms |
109980 KB |
Output is correct |
69 |
Correct |
875 ms |
110728 KB |
Output is correct |
70 |
Correct |
905 ms |
110892 KB |
Output is correct |
71 |
Correct |
866 ms |
110860 KB |
Output is correct |
72 |
Correct |
894 ms |
110748 KB |
Output is correct |
73 |
Correct |
840 ms |
110892 KB |
Output is correct |
74 |
Correct |
828 ms |
110744 KB |
Output is correct |
75 |
Correct |
749 ms |
109980 KB |
Output is correct |
76 |
Correct |
788 ms |
111264 KB |
Output is correct |
77 |
Correct |
803 ms |
110296 KB |
Output is correct |
78 |
Correct |
809 ms |
111160 KB |
Output is correct |
79 |
Correct |
804 ms |
111212 KB |
Output is correct |
80 |
Correct |
772 ms |
111096 KB |
Output is correct |
81 |
Correct |
1 ms |
344 KB |
Output is correct |
82 |
Correct |
2 ms |
1880 KB |
Output is correct |
83 |
Correct |
3 ms |
1880 KB |
Output is correct |
84 |
Correct |
178 ms |
110796 KB |
Output is correct |
85 |
Correct |
164 ms |
110920 KB |
Output is correct |
86 |
Correct |
167 ms |
110768 KB |
Output is correct |
87 |
Correct |
124 ms |
111104 KB |
Output is correct |
88 |
Correct |
112 ms |
110024 KB |
Output is correct |
89 |
Correct |
184 ms |
110776 KB |
Output is correct |
90 |
Correct |
159 ms |
110744 KB |
Output is correct |
91 |
Correct |
166 ms |
110672 KB |
Output is correct |
92 |
Correct |
117 ms |
111212 KB |
Output is correct |
93 |
Correct |
121 ms |
110628 KB |
Output is correct |
94 |
Correct |
2 ms |
1880 KB |
Output is correct |
95 |
Correct |
2 ms |
1880 KB |
Output is correct |
96 |
Correct |
2 ms |
2132 KB |
Output is correct |
97 |
Correct |
2 ms |
1880 KB |
Output is correct |
98 |
Correct |
3 ms |
1880 KB |
Output is correct |
99 |
Correct |
2 ms |
1880 KB |
Output is correct |
100 |
Correct |
2 ms |
1880 KB |
Output is correct |
101 |
Correct |
3 ms |
1880 KB |
Output is correct |
102 |
Correct |
2 ms |
1880 KB |
Output is correct |
103 |
Correct |
2 ms |
1880 KB |
Output is correct |
104 |
Correct |
712 ms |
97736 KB |
Output is correct |
105 |
Correct |
867 ms |
110916 KB |
Output is correct |
106 |
Correct |
894 ms |
110748 KB |
Output is correct |
107 |
Correct |
865 ms |
110752 KB |
Output is correct |
108 |
Correct |
842 ms |
110748 KB |
Output is correct |
109 |
Correct |
900 ms |
110816 KB |
Output is correct |
110 |
Correct |
863 ms |
110688 KB |
Output is correct |
111 |
Correct |
764 ms |
109992 KB |
Output is correct |
112 |
Correct |
779 ms |
111400 KB |
Output is correct |
113 |
Correct |
775 ms |
110780 KB |
Output is correct |
114 |
Correct |
764 ms |
111212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
380 ms |
63840 KB |
Output is correct |
2 |
Correct |
830 ms |
111256 KB |
Output is correct |
3 |
Correct |
839 ms |
111216 KB |
Output is correct |
4 |
Correct |
805 ms |
110084 KB |
Output is correct |
5 |
Correct |
829 ms |
111260 KB |
Output is correct |
6 |
Correct |
779 ms |
111260 KB |
Output is correct |
7 |
Correct |
771 ms |
111232 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
2 ms |
1880 KB |
Output is correct |
10 |
Correct |
2 ms |
1880 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
2 ms |
1880 KB |
Output is correct |
13 |
Correct |
2 ms |
1880 KB |
Output is correct |
14 |
Correct |
2 ms |
1880 KB |
Output is correct |
15 |
Correct |
2 ms |
1880 KB |
Output is correct |
16 |
Correct |
2 ms |
1880 KB |
Output is correct |
17 |
Correct |
2 ms |
1948 KB |
Output is correct |
18 |
Correct |
3 ms |
1880 KB |
Output is correct |
19 |
Correct |
2 ms |
1880 KB |
Output is correct |
20 |
Correct |
2 ms |
1880 KB |
Output is correct |
21 |
Correct |
2 ms |
1880 KB |
Output is correct |
22 |
Correct |
0 ms |
344 KB |
Output is correct |
23 |
Correct |
2 ms |
1880 KB |
Output is correct |
24 |
Correct |
2 ms |
1880 KB |
Output is correct |
25 |
Correct |
2 ms |
1880 KB |
Output is correct |
26 |
Correct |
2 ms |
1888 KB |
Output is correct |
27 |
Correct |
2 ms |
2132 KB |
Output is correct |
28 |
Correct |
2 ms |
1880 KB |
Output is correct |
29 |
Correct |
2 ms |
1880 KB |
Output is correct |
30 |
Correct |
2 ms |
1880 KB |
Output is correct |
31 |
Correct |
2 ms |
2132 KB |
Output is correct |
32 |
Correct |
2 ms |
1880 KB |
Output is correct |
33 |
Correct |
2 ms |
1880 KB |
Output is correct |
34 |
Correct |
2 ms |
1880 KB |
Output is correct |
35 |
Correct |
1 ms |
856 KB |
Output is correct |
36 |
Correct |
2 ms |
1880 KB |
Output is correct |
37 |
Correct |
2 ms |
1880 KB |
Output is correct |
38 |
Correct |
2 ms |
1880 KB |
Output is correct |
39 |
Correct |
2 ms |
1880 KB |
Output is correct |
40 |
Correct |
2 ms |
1880 KB |
Output is correct |
41 |
Correct |
3 ms |
1880 KB |
Output is correct |
42 |
Correct |
2 ms |
1888 KB |
Output is correct |
43 |
Correct |
2 ms |
1880 KB |
Output is correct |
44 |
Correct |
2 ms |
1880 KB |
Output is correct |
45 |
Correct |
2 ms |
1880 KB |
Output is correct |
46 |
Correct |
101 ms |
69812 KB |
Output is correct |
47 |
Correct |
158 ms |
110812 KB |
Output is correct |
48 |
Correct |
158 ms |
110688 KB |
Output is correct |
49 |
Correct |
157 ms |
110752 KB |
Output is correct |
50 |
Correct |
159 ms |
110784 KB |
Output is correct |
51 |
Correct |
156 ms |
110784 KB |
Output is correct |
52 |
Correct |
161 ms |
110832 KB |
Output is correct |
53 |
Correct |
114 ms |
110084 KB |
Output is correct |
54 |
Correct |
111 ms |
111300 KB |
Output is correct |
55 |
Correct |
109 ms |
110392 KB |
Output is correct |
56 |
Correct |
111 ms |
111008 KB |
Output is correct |
57 |
Correct |
155 ms |
110676 KB |
Output is correct |
58 |
Correct |
160 ms |
110920 KB |
Output is correct |
59 |
Correct |
160 ms |
110792 KB |
Output is correct |
60 |
Correct |
110 ms |
111268 KB |
Output is correct |
61 |
Correct |
112 ms |
109996 KB |
Output is correct |
62 |
Correct |
156 ms |
110748 KB |
Output is correct |
63 |
Correct |
170 ms |
110804 KB |
Output is correct |
64 |
Correct |
155 ms |
110832 KB |
Output is correct |
65 |
Correct |
110 ms |
111280 KB |
Output is correct |
66 |
Correct |
108 ms |
110636 KB |
Output is correct |
67 |
Correct |
159 ms |
106812 KB |
Output is correct |
68 |
Correct |
163 ms |
110736 KB |
Output is correct |
69 |
Correct |
162 ms |
110748 KB |
Output is correct |
70 |
Correct |
155 ms |
110712 KB |
Output is correct |
71 |
Correct |
186 ms |
110748 KB |
Output is correct |
72 |
Correct |
158 ms |
110744 KB |
Output is correct |
73 |
Correct |
156 ms |
110788 KB |
Output is correct |
74 |
Correct |
117 ms |
109976 KB |
Output is correct |
75 |
Correct |
113 ms |
111296 KB |
Output is correct |
76 |
Correct |
145 ms |
110924 KB |
Output is correct |
77 |
Correct |
117 ms |
111276 KB |
Output is correct |
78 |
Correct |
681 ms |
109980 KB |
Output is correct |
79 |
Correct |
875 ms |
110728 KB |
Output is correct |
80 |
Correct |
905 ms |
110892 KB |
Output is correct |
81 |
Correct |
866 ms |
110860 KB |
Output is correct |
82 |
Correct |
894 ms |
110748 KB |
Output is correct |
83 |
Correct |
840 ms |
110892 KB |
Output is correct |
84 |
Correct |
828 ms |
110744 KB |
Output is correct |
85 |
Correct |
749 ms |
109980 KB |
Output is correct |
86 |
Correct |
788 ms |
111264 KB |
Output is correct |
87 |
Correct |
803 ms |
110296 KB |
Output is correct |
88 |
Correct |
809 ms |
111160 KB |
Output is correct |
89 |
Correct |
804 ms |
111212 KB |
Output is correct |
90 |
Correct |
772 ms |
111096 KB |
Output is correct |
91 |
Correct |
1 ms |
344 KB |
Output is correct |
92 |
Correct |
2 ms |
1880 KB |
Output is correct |
93 |
Correct |
3 ms |
1880 KB |
Output is correct |
94 |
Correct |
178 ms |
110796 KB |
Output is correct |
95 |
Correct |
164 ms |
110920 KB |
Output is correct |
96 |
Correct |
167 ms |
110768 KB |
Output is correct |
97 |
Correct |
124 ms |
111104 KB |
Output is correct |
98 |
Correct |
112 ms |
110024 KB |
Output is correct |
99 |
Correct |
184 ms |
110776 KB |
Output is correct |
100 |
Correct |
159 ms |
110744 KB |
Output is correct |
101 |
Correct |
166 ms |
110672 KB |
Output is correct |
102 |
Correct |
117 ms |
111212 KB |
Output is correct |
103 |
Correct |
121 ms |
110628 KB |
Output is correct |
104 |
Correct |
2 ms |
1880 KB |
Output is correct |
105 |
Correct |
2 ms |
1880 KB |
Output is correct |
106 |
Correct |
2 ms |
2132 KB |
Output is correct |
107 |
Correct |
2 ms |
1880 KB |
Output is correct |
108 |
Correct |
3 ms |
1880 KB |
Output is correct |
109 |
Correct |
2 ms |
1880 KB |
Output is correct |
110 |
Correct |
2 ms |
1880 KB |
Output is correct |
111 |
Correct |
3 ms |
1880 KB |
Output is correct |
112 |
Correct |
2 ms |
1880 KB |
Output is correct |
113 |
Correct |
2 ms |
1880 KB |
Output is correct |
114 |
Correct |
224 ms |
24108 KB |
Output is correct |
115 |
Correct |
892 ms |
110912 KB |
Output is correct |
116 |
Correct |
854 ms |
110896 KB |
Output is correct |
117 |
Correct |
837 ms |
110748 KB |
Output is correct |
118 |
Correct |
858 ms |
110868 KB |
Output is correct |
119 |
Correct |
854 ms |
110908 KB |
Output is correct |
120 |
Correct |
818 ms |
110752 KB |
Output is correct |
121 |
Correct |
706 ms |
109980 KB |
Output is correct |
122 |
Correct |
715 ms |
111168 KB |
Output is correct |
123 |
Correct |
694 ms |
110748 KB |
Output is correct |
124 |
Correct |
730 ms |
111028 KB |
Output is correct |
125 |
Correct |
168 ms |
110912 KB |
Output is correct |
126 |
Correct |
157 ms |
110788 KB |
Output is correct |
127 |
Correct |
157 ms |
110756 KB |
Output is correct |
128 |
Correct |
111 ms |
111268 KB |
Output is correct |
129 |
Correct |
108 ms |
110616 KB |
Output is correct |
130 |
Correct |
154 ms |
106808 KB |
Output is correct |
131 |
Correct |
161 ms |
110868 KB |
Output is correct |
132 |
Correct |
167 ms |
110956 KB |
Output is correct |
133 |
Correct |
158 ms |
111000 KB |
Output is correct |
134 |
Correct |
156 ms |
110764 KB |
Output is correct |
135 |
Correct |
162 ms |
111188 KB |
Output is correct |
136 |
Correct |
156 ms |
110880 KB |
Output is correct |
137 |
Correct |
111 ms |
110000 KB |
Output is correct |
138 |
Correct |
112 ms |
111272 KB |
Output is correct |
139 |
Correct |
114 ms |
110748 KB |
Output is correct |
140 |
Correct |
111 ms |
111260 KB |
Output is correct |
141 |
Correct |
2 ms |
1880 KB |
Output is correct |
142 |
Correct |
2 ms |
1880 KB |
Output is correct |
143 |
Correct |
2 ms |
1880 KB |
Output is correct |
144 |
Correct |
2 ms |
1880 KB |
Output is correct |
145 |
Correct |
2 ms |
1880 KB |
Output is correct |
146 |
Correct |
1 ms |
856 KB |
Output is correct |
147 |
Correct |
2 ms |
1880 KB |
Output is correct |
148 |
Correct |
2 ms |
1880 KB |
Output is correct |
149 |
Correct |
2 ms |
1880 KB |
Output is correct |
150 |
Correct |
2 ms |
1880 KB |
Output is correct |
151 |
Correct |
2 ms |
1880 KB |
Output is correct |
152 |
Correct |
2 ms |
1880 KB |
Output is correct |
153 |
Correct |
2 ms |
1880 KB |
Output is correct |
154 |
Correct |
2 ms |
1880 KB |
Output is correct |
155 |
Correct |
2 ms |
1880 KB |
Output is correct |
156 |
Correct |
2 ms |
1880 KB |
Output is correct |
157 |
Correct |
712 ms |
97736 KB |
Output is correct |
158 |
Correct |
867 ms |
110916 KB |
Output is correct |
159 |
Correct |
894 ms |
110748 KB |
Output is correct |
160 |
Correct |
865 ms |
110752 KB |
Output is correct |
161 |
Correct |
842 ms |
110748 KB |
Output is correct |
162 |
Correct |
900 ms |
110816 KB |
Output is correct |
163 |
Correct |
863 ms |
110688 KB |
Output is correct |
164 |
Correct |
764 ms |
109992 KB |
Output is correct |
165 |
Correct |
779 ms |
111400 KB |
Output is correct |
166 |
Correct |
775 ms |
110780 KB |
Output is correct |
167 |
Correct |
764 ms |
111212 KB |
Output is correct |
168 |
Correct |
0 ms |
344 KB |
Output is correct |
169 |
Correct |
605 ms |
35908 KB |
Output is correct |
170 |
Correct |
1048 ms |
110788 KB |
Output is correct |
171 |
Correct |
1095 ms |
110756 KB |
Output is correct |
172 |
Correct |
1020 ms |
110788 KB |
Output is correct |
173 |
Correct |
1071 ms |
111012 KB |
Output is correct |
174 |
Correct |
1079 ms |
110864 KB |
Output is correct |
175 |
Correct |
1068 ms |
110716 KB |
Output is correct |
176 |
Correct |
798 ms |
109892 KB |
Output is correct |
177 |
Correct |
826 ms |
111276 KB |
Output is correct |
178 |
Correct |
781 ms |
111004 KB |
Output is correct |
179 |
Correct |
815 ms |
111040 KB |
Output is correct |