#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, h[maxn], pref[maxn], peak_pos;
int cnt = 0;
int par[maxn], rnk[maxn];
int find_leader(int v)
{
return (v == par[v]) ? v : par[v] = find_leader(par[v]);
}
void unite(int v, int u)
{
v = find_leader(v);
u = find_leader(u);
if (v == u)
return;
if (rnk[v] < rnk[u])
swap(v, u);
rnk[v] += rnk[u];
par[u] = v;
}
int dp[maxn], bef[maxn], aft[maxn];
struct node
{
int max_number, min_number;
node(int _max_number = 0, int _min_number = 2e9)
{
max_number = _max_number;
min_number = _min_number;
}
};
node tree[4 * maxn];
node merge_node(node left, node right)
{
node comb;
comb.max_number = max(left.max_number, right.max_number);
comb.min_number = min(left.min_number, right.min_number);
return comb;
}
void build_tree(int root, int left, int right)
{
if (left == right)
{
tree[root] = node(h[left], h[left]);
return;
}
int mid = (left + right) / 2;
build_tree(root * 2, left, mid);
build_tree(root * 2 + 1, mid + 1, right);
tree[root] = merge_node(tree[root * 2], tree[root * 2 + 1]);
}
void update(int root, int left, int right, int pos, int val)
{
if (left == right)
{
tree[root] = val;
return;
}
int mid = (left + right) / 2;
if (pos <= mid)
update(root * 2, left, mid, pos, val);
else
update(root * 2 + 1, mid + 1, right, pos, val);
tree[root] = merge_node(tree[root * 2], tree[root * 2 + 1]);
}
node query(int root, int left, int right, int qleft, int qright)
{
if (left > qright || right < qleft)
return 0;
if (left >= qleft && right <= qright)
return tree[root];
int mid = (left + right) / 2;
return merge_node(query(root * 2, left, mid, qleft, qright),
query(root * 2 + 1, mid + 1, right, qleft, qright));
}
int find_rightmost(int root, int left, int right, int qleft, int qright, int val)
{
///cout << root << " " << left << " " << right << " " << qleft << " " << qright << " " << val << endl;
if (tree[root].max_number < val ||
left > qright || right < qleft)
return 0;
if (left == right)
return left;
int mid = (left + right) / 2;
if (left >= qleft && right <= qright)
{
if (tree[root * 2 + 1].max_number >= val)
return find_rightmost(root * 2 + 1, mid + 1, right, qleft, qright, val);
return find_rightmost(root * 2, left, mid, qleft, qright, val);
}
return max(find_rightmost(root * 2, left, mid, qleft, qright, val),
find_rightmost(root * 2 + 1, mid + 1, right, qleft, qright, val));
}
int find_leftmost(int root, int left, int right, int qleft, int qright, int val)
{
if (tree[root].max_number < val ||
left > qright || right < qleft)
return n + 1;
if (left == right)
return left;
int mid = (left + right) / 2;
if (left >= qleft && right <= qright)
{
if (tree[root * 2].max_number >= val)
return find_leftmost(root * 2, left, mid, qleft, qright, val);
return find_leftmost(root * 2 + 1, mid + 1, right, qleft, qright, val);
}
return min(find_leftmost(root * 2, left, mid, qleft, qright, val),
find_leftmost(root * 2 + 1, mid + 1, right, qleft, qright, val));
}
struct diff_node
{
int max_number, min_number;
int diff_to_right;
int diff_to_left;
diff_node()
{
max_number = 0;
min_number = 2e9;
diff_to_right = 0;
diff_to_left = 0;
}
};
diff_node merge_diff(diff_node dn1, diff_node dn2)
{
diff_node res;
res.max_number = max(dn1.max_number, dn2.max_number);
res.min_number = min(dn1.min_number, dn2.min_number);
res.diff_to_right = max(dn2.max_number - dn1.min_number, max(dn1.diff_to_right, dn2.diff_to_right));
res.diff_to_left = max(dn1.max_number - dn2.min_number, max(dn1.diff_to_left, dn2.diff_to_left));
return res;
}
diff_node diff_tree[4 * maxn];
void build_diff_tree(int root, int left, int right)
{
if (left == right)
{
diff_tree[root].max_number = diff_tree[root].min_number = h[left];
return;
}
int mid = (left + right) / 2;
build_diff_tree(root * 2, left, mid);
build_diff_tree(root * 2 + 1, mid + 1, right);
diff_tree[root] = merge_diff(diff_tree[root * 2], diff_tree[root * 2 + 1]);
}
diff_node diff_query(int root, int left, int right, int qleft, int qright)
{
if (left > qright || right < qleft)
return diff_node();
if (left >= qleft && right <= qright)
return diff_tree[root];
int mid = (left + right) / 2;
return merge_diff(diff_query(root * 2, left, mid, qleft, qright),
diff_query(root * 2 + 1, mid + 1, right, qleft, qright));
}
vector < pair < int, int > > val;
unordered_map < int, int > rev;
vector < int > merge_tree[4 * maxn];
void conquer(int left_root, int right_root, int root)
{
int idx1 = 0, idx2 = 0;
while(idx1 < merge_tree[left_root].size() && idx2 < merge_tree[right_root].size())
{
if (merge_tree[left_root][idx1] < merge_tree[right_root][idx2])
{
merge_tree[root].push_back(merge_tree[left_root][idx1 ++]);
}
else
{
merge_tree[root].push_back(merge_tree[right_root][idx2 ++]);
}
}
while(idx1 < merge_tree[left_root].size())
merge_tree[root].push_back(merge_tree[left_root][idx1 ++]);
while(idx2 < merge_tree[right_root].size())
merge_tree[root].push_back(merge_tree[right_root][idx2 ++]);
}
void divide(int root, int left, int right)
{
if (left == right)
{
merge_tree[root].push_back(val[left].second);
return;
}
int mid = (left + right) / 2;
divide(root * 2, left, mid);
divide(root * 2 + 1, mid + 1, right);
conquer(root * 2, root * 2 + 1, root);
}
int query_max_under_node(int root, int val)
{
int lf = 0, rf = (int)(merge_tree[root].size()) - 1;
while(lf <= rf)
{
int mf = (lf + rf) / 2;
if (merge_tree[root][mf] <= val)
lf = mf + 1;
else
rf = mf - 1;
}
if (rf < 0)
return 0;
return merge_tree[root][rf];
}
int query_min_above_node(int root, int val)
{
int lf = 0, rf = (int)(merge_tree[root].size()) - 1;
while(lf <= rf)
{
int mf = (lf + rf) / 2;
if (merge_tree[root][mf] >= val)
rf = mf - 1;
else
lf = mf + 1;
}
if (lf == merge_tree[root].size())
return n + 1;
return merge_tree[root][lf];
}
int query_min_above(int root, int left, int right, int qleft, int qright, int val)
{
if (left > qright || right < qleft)
return n + 1;
if (left >= qleft && right <= qright)
return query_min_above_node(root, val);
int mid = (left + right) / 2;
return min(query_min_above(root * 2, left, mid, qleft, qright, val),
query_min_above(root * 2 + 1, mid + 1, right, qleft, qright, val));
}
int query_max_under(int root, int left, int right, int qleft, int qright, int val)
{
if (left > qright || right < qleft)
return 0;
if (left >= qleft && right <= qright)
return query_max_under_node(root, val);
int mid = (left + right) / 2;
return max(query_max_under(root * 2, left, mid, qleft, qright, val),
query_max_under(root * 2 + 1, mid + 1, right, qleft, qright, val));
}
int query_between_node(int root, int min_val, int max_val)
{
int lf = 0, rf = (int)(merge_tree[root].size()) - 1;
while(lf <= rf)
{
int mf = (lf + rf) / 2;
if (merge_tree[root][mf] <= max_val)
lf = mf + 1;
else
rf = mf - 1;
}
int rb = rf;
lf = 0;
rf = (int)(merge_tree[root].size()) - 1;
while(lf <= rf)
{
int mf = (lf + rf) / 2;
if (merge_tree[root][mf] >= min_val)
rf = mf - 1;
else
lf = mf + 1;
}
int lb = lf;
return (rb - lb + 1);
}
int query_between(int root, int left, int right, int qleft, int qright, int min_val, int max_val)
{
if (left > qright || right < qleft)
return 0;
if (left >= qleft && right <= qright)
return query_between_node(root, min_val, max_val);
int mid = (left + right) / 2;
return query_between(root * 2, left, mid, qleft, qright, min_val, max_val) +
query_between(root * 2 + 1, mid + 1, right, qleft, qright, min_val, max_val);
}
void init(int N, std::vector<int> H)
{
n = N;
for (int i = 0; i < n; i ++)
h[i + 1] = H[i], rev[H[i]] = i + 1;
for (int i = 1; i <= n; i ++)
if (h[i] > h[i - 1] && h[i] > h[i + 1])
cnt ++;
for (int i = 2; i < n; i ++)
{
pref[i] = pref[i - 1];
if (h[i] > h[i - 1] && h[i] > h[i + 1])
{
pref[i] ++, peak_pos = i;
}
}
build_tree(1, 1, n);
build_diff_tree(1, 1, n);
vector < int > st;
st.push_back(0);
for (int i = 1; i <= n; i ++)
{
while(!st.empty() && h[st.back()] >= h[i])
st.pop_back();
bef[i] = st.back();
st.push_back(i);
}
st.clear();
st.push_back(n + 1);
for (int i = n; i > 0; i --)
{
while(!st.empty() && h[st.back()] >= h[i])
st.pop_back();
aft[i] = st.back();
st.push_back(i);
}
for (int i = 1; i <= n; i ++)
{
///cout << bef[i] << " " << aft[i] << endl;
int h1 = 0, h2 = 0;
if (bef[i] != i - 1)
h1 = query(1, 1, n, bef[i] + 1, i - 1).max_number;
if (bef[i] == 0)
h1 = 2e9 + 10;
if (aft[i] != i + 1)
h2 = query(1, 1, n, i + 1, aft[i] - 1).max_number;
if (aft[i] == n + 1)
h2 = 2e9 + 10;
val.push_back({min(h1, h2) - h[i], i});
///cout << query(1, 1, n, bef[i] + 1)
}
sort(val.begin(), val.end());
divide(1, 0, val.size() - 1);
//for (int v : val)
// cout << v << " ";
// cout << endl;
}
vector < int > act[maxn];
int cnt_query = 0;
int max_towers(int L, int R, int D)
{
L ++;
R ++;
cnt_query ++;
int lf = 0, rf = (int)(val.size()) - 1;
while(lf <= rf)
{
int mf = (lf + rf) / 2;
if (val[mf].first < D)
lf = mf + 1;
else
rf = mf - 1;
}
///vector < int > towers;
int leftmost = n + 1, rightmost = 0, ans = 0;
rightmost = query_max_under(1, 0, val.size() - 1, lf, val.size() - 1, R);
leftmost = query_min_above(1, 0, val.size() - 1, lf, val.size() - 1, L);
ans = query_between(1, 0, val.size() - 1, lf, val.size() - 1, L, R);
/**for (int i = lf; i < val.size(); i ++)
{
if (val[i].second >= L && val[i].second <= R)
{
///ans ++;
///towers.push_back(val[i].second);
///leftmost = min(leftmost, val[i].second);
///rightmost = max(rightmost, val[i].second);
}
}*/
///cout << leftmost << " " << rightmost << endl;
if (leftmost > rightmost)
{
int lowest_tower = rev[query(1, 1, n, L, R).min_number];
leftmost = lowest_tower;
rightmost = lowest_tower;
ans = 1;
}
int highest_tower = 0;
int La = find_rightmost(1, 1, n, 1, leftmost, h[leftmost] + D);
diff_node dn = diff_query(1, 1, n, L, La);
if (dn.diff_to_right >= D)
ans ++;
///cout << La << endl;
///cout << leftmost << " " << rightmost << endl;
/**for (int tower = leftmost - 1; tower >= L; tower --)
{
if (tower <= La && h[tower] + D <= highest_tower &&
highest_tower >= h[leftmost] + D)
{
ans ++;
break;
}
highest_tower = max(highest_tower, h[tower]);
}*/
highest_tower = 0;
int Ra = find_leftmost(1, 1, n, rightmost, n, h[rightmost] + D);
dn = diff_query(1, 1, n, Ra, R);
if (dn.diff_to_left >= D)
ans ++;
/**for (int tower = rightmost + 1; tower <= R; tower ++)
{
if (tower >= Ra && h[tower] + D <= highest_tower &&
highest_tower >= h[rightmost] + D)
{
ans ++;
break;
}
highest_tower = max(highest_tower, h[tower]);
}*/
return ans;
}
Compilation message
towers.cpp: In function 'void conquer(int, int, int)':
towers.cpp:203:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
203 | while(idx1 < merge_tree[left_root].size() && idx2 < merge_tree[right_root].size())
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
towers.cpp:203:55: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
203 | while(idx1 < merge_tree[left_root].size() && idx2 < merge_tree[right_root].size())
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
towers.cpp:215:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
215 | while(idx1 < merge_tree[left_root].size())
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
towers.cpp:218:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
218 | while(idx2 < merge_tree[right_root].size())
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
towers.cpp: In function 'int query_min_above_node(int, int)':
towers.cpp:265:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
265 | if (lf == merge_tree[root].size())
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:453:9: warning: variable 'highest_tower' set but not used [-Wunused-but-set-variable]
453 | int highest_tower = 0;
| ^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
521 ms |
33328 KB |
Output is correct |
2 |
Correct |
1086 ms |
42940 KB |
Output is correct |
3 |
Correct |
1086 ms |
42904 KB |
Output is correct |
4 |
Correct |
1055 ms |
42864 KB |
Output is correct |
5 |
Correct |
1047 ms |
42936 KB |
Output is correct |
6 |
Correct |
1198 ms |
42896 KB |
Output is correct |
7 |
Correct |
963 ms |
42924 KB |
Output is correct |
8 |
Correct |
11 ms |
21456 KB |
Output is correct |
9 |
Correct |
12 ms |
21768 KB |
Output is correct |
10 |
Correct |
12 ms |
21796 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
21460 KB |
Output is correct |
2 |
Correct |
12 ms |
21712 KB |
Output is correct |
3 |
Correct |
12 ms |
21712 KB |
Output is correct |
4 |
Correct |
11 ms |
21712 KB |
Output is correct |
5 |
Correct |
12 ms |
21712 KB |
Output is correct |
6 |
Correct |
12 ms |
21708 KB |
Output is correct |
7 |
Correct |
14 ms |
21744 KB |
Output is correct |
8 |
Correct |
12 ms |
21712 KB |
Output is correct |
9 |
Correct |
14 ms |
21720 KB |
Output is correct |
10 |
Correct |
14 ms |
21764 KB |
Output is correct |
11 |
Correct |
12 ms |
21712 KB |
Output is correct |
12 |
Correct |
12 ms |
21328 KB |
Output is correct |
13 |
Correct |
15 ms |
21712 KB |
Output is correct |
14 |
Correct |
12 ms |
21712 KB |
Output is correct |
15 |
Correct |
13 ms |
21712 KB |
Output is correct |
16 |
Correct |
12 ms |
21712 KB |
Output is correct |
17 |
Correct |
12 ms |
21712 KB |
Output is correct |
18 |
Correct |
12 ms |
21712 KB |
Output is correct |
19 |
Correct |
11 ms |
21712 KB |
Output is correct |
20 |
Correct |
12 ms |
21696 KB |
Output is correct |
21 |
Correct |
12 ms |
21736 KB |
Output is correct |
22 |
Correct |
11 ms |
21764 KB |
Output is correct |
23 |
Correct |
12 ms |
21712 KB |
Output is correct |
24 |
Correct |
13 ms |
21776 KB |
Output is correct |
25 |
Correct |
13 ms |
21584 KB |
Output is correct |
26 |
Correct |
15 ms |
21712 KB |
Output is correct |
27 |
Correct |
14 ms |
21680 KB |
Output is correct |
28 |
Correct |
12 ms |
21744 KB |
Output is correct |
29 |
Correct |
12 ms |
21792 KB |
Output is correct |
30 |
Correct |
12 ms |
21712 KB |
Output is correct |
31 |
Correct |
11 ms |
21752 KB |
Output is correct |
32 |
Correct |
11 ms |
21712 KB |
Output is correct |
33 |
Correct |
11 ms |
21712 KB |
Output is correct |
34 |
Correct |
12 ms |
21712 KB |
Output is correct |
35 |
Correct |
11 ms |
21712 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
21460 KB |
Output is correct |
2 |
Correct |
12 ms |
21712 KB |
Output is correct |
3 |
Correct |
12 ms |
21712 KB |
Output is correct |
4 |
Correct |
11 ms |
21712 KB |
Output is correct |
5 |
Correct |
12 ms |
21712 KB |
Output is correct |
6 |
Correct |
12 ms |
21708 KB |
Output is correct |
7 |
Correct |
14 ms |
21744 KB |
Output is correct |
8 |
Correct |
12 ms |
21712 KB |
Output is correct |
9 |
Correct |
14 ms |
21720 KB |
Output is correct |
10 |
Correct |
14 ms |
21764 KB |
Output is correct |
11 |
Correct |
12 ms |
21712 KB |
Output is correct |
12 |
Correct |
12 ms |
21328 KB |
Output is correct |
13 |
Correct |
15 ms |
21712 KB |
Output is correct |
14 |
Correct |
12 ms |
21712 KB |
Output is correct |
15 |
Correct |
13 ms |
21712 KB |
Output is correct |
16 |
Correct |
12 ms |
21712 KB |
Output is correct |
17 |
Correct |
12 ms |
21712 KB |
Output is correct |
18 |
Correct |
12 ms |
21712 KB |
Output is correct |
19 |
Correct |
11 ms |
21712 KB |
Output is correct |
20 |
Correct |
12 ms |
21696 KB |
Output is correct |
21 |
Correct |
12 ms |
21736 KB |
Output is correct |
22 |
Correct |
11 ms |
21764 KB |
Output is correct |
23 |
Correct |
12 ms |
21712 KB |
Output is correct |
24 |
Correct |
13 ms |
21776 KB |
Output is correct |
25 |
Correct |
13 ms |
21584 KB |
Output is correct |
26 |
Correct |
15 ms |
21712 KB |
Output is correct |
27 |
Correct |
14 ms |
21680 KB |
Output is correct |
28 |
Correct |
12 ms |
21744 KB |
Output is correct |
29 |
Correct |
12 ms |
21792 KB |
Output is correct |
30 |
Correct |
12 ms |
21712 KB |
Output is correct |
31 |
Correct |
11 ms |
21752 KB |
Output is correct |
32 |
Correct |
11 ms |
21712 KB |
Output is correct |
33 |
Correct |
11 ms |
21712 KB |
Output is correct |
34 |
Correct |
12 ms |
21712 KB |
Output is correct |
35 |
Correct |
11 ms |
21712 KB |
Output is correct |
36 |
Correct |
68 ms |
33804 KB |
Output is correct |
37 |
Correct |
103 ms |
42540 KB |
Output is correct |
38 |
Correct |
106 ms |
42556 KB |
Output is correct |
39 |
Correct |
113 ms |
42592 KB |
Output is correct |
40 |
Correct |
99 ms |
42540 KB |
Output is correct |
41 |
Correct |
103 ms |
42452 KB |
Output is correct |
42 |
Correct |
99 ms |
42604 KB |
Output is correct |
43 |
Correct |
89 ms |
42900 KB |
Output is correct |
44 |
Correct |
87 ms |
42896 KB |
Output is correct |
45 |
Correct |
88 ms |
42792 KB |
Output is correct |
46 |
Correct |
92 ms |
42680 KB |
Output is correct |
47 |
Correct |
117 ms |
42508 KB |
Output is correct |
48 |
Correct |
105 ms |
42540 KB |
Output is correct |
49 |
Correct |
99 ms |
42556 KB |
Output is correct |
50 |
Correct |
86 ms |
42840 KB |
Output is correct |
51 |
Correct |
86 ms |
42868 KB |
Output is correct |
52 |
Correct |
102 ms |
42540 KB |
Output is correct |
53 |
Correct |
102 ms |
42492 KB |
Output is correct |
54 |
Correct |
109 ms |
42556 KB |
Output is correct |
55 |
Correct |
106 ms |
42904 KB |
Output is correct |
56 |
Correct |
101 ms |
42708 KB |
Output is correct |
57 |
Correct |
100 ms |
41952 KB |
Output is correct |
58 |
Correct |
103 ms |
42492 KB |
Output is correct |
59 |
Correct |
110 ms |
42592 KB |
Output is correct |
60 |
Correct |
101 ms |
42464 KB |
Output is correct |
61 |
Correct |
99 ms |
42444 KB |
Output is correct |
62 |
Correct |
103 ms |
42456 KB |
Output is correct |
63 |
Correct |
104 ms |
42504 KB |
Output is correct |
64 |
Correct |
87 ms |
42936 KB |
Output is correct |
65 |
Correct |
86 ms |
42880 KB |
Output is correct |
66 |
Correct |
89 ms |
42708 KB |
Output is correct |
67 |
Correct |
95 ms |
42928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1016 ms |
42516 KB |
Output is correct |
2 |
Correct |
1472 ms |
42508 KB |
Output is correct |
3 |
Correct |
1338 ms |
42556 KB |
Output is correct |
4 |
Correct |
1151 ms |
42496 KB |
Output is correct |
5 |
Correct |
1247 ms |
42560 KB |
Output is correct |
6 |
Correct |
1077 ms |
42536 KB |
Output is correct |
7 |
Correct |
1517 ms |
42544 KB |
Output is correct |
8 |
Correct |
1062 ms |
42944 KB |
Output is correct |
9 |
Correct |
1203 ms |
42936 KB |
Output is correct |
10 |
Correct |
1152 ms |
42720 KB |
Output is correct |
11 |
Correct |
1123 ms |
42756 KB |
Output is correct |
12 |
Correct |
1101 ms |
42948 KB |
Output is correct |
13 |
Correct |
1197 ms |
42864 KB |
Output is correct |
14 |
Correct |
12 ms |
21344 KB |
Output is correct |
15 |
Correct |
14 ms |
21712 KB |
Output is correct |
16 |
Correct |
11 ms |
21712 KB |
Output is correct |
17 |
Correct |
103 ms |
42464 KB |
Output is correct |
18 |
Correct |
98 ms |
42456 KB |
Output is correct |
19 |
Correct |
105 ms |
42540 KB |
Output is correct |
20 |
Correct |
91 ms |
42924 KB |
Output is correct |
21 |
Correct |
84 ms |
42940 KB |
Output is correct |
22 |
Correct |
104 ms |
42460 KB |
Output is correct |
23 |
Correct |
100 ms |
42524 KB |
Output is correct |
24 |
Correct |
110 ms |
42496 KB |
Output is correct |
25 |
Correct |
95 ms |
42936 KB |
Output is correct |
26 |
Correct |
103 ms |
42676 KB |
Output is correct |
27 |
Correct |
13 ms |
21704 KB |
Output is correct |
28 |
Correct |
12 ms |
21712 KB |
Output is correct |
29 |
Correct |
12 ms |
21712 KB |
Output is correct |
30 |
Correct |
12 ms |
21792 KB |
Output is correct |
31 |
Correct |
12 ms |
21764 KB |
Output is correct |
32 |
Correct |
12 ms |
21712 KB |
Output is correct |
33 |
Correct |
13 ms |
21700 KB |
Output is correct |
34 |
Correct |
12 ms |
21700 KB |
Output is correct |
35 |
Correct |
12 ms |
21712 KB |
Output is correct |
36 |
Correct |
11 ms |
21712 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
285 ms |
26364 KB |
Output is correct |
2 |
Correct |
1096 ms |
42656 KB |
Output is correct |
3 |
Correct |
1113 ms |
42448 KB |
Output is correct |
4 |
Correct |
1080 ms |
42540 KB |
Output is correct |
5 |
Correct |
1204 ms |
42448 KB |
Output is correct |
6 |
Correct |
1010 ms |
42556 KB |
Output is correct |
7 |
Correct |
1130 ms |
42512 KB |
Output is correct |
8 |
Correct |
993 ms |
42924 KB |
Output is correct |
9 |
Correct |
1046 ms |
42876 KB |
Output is correct |
10 |
Correct |
1069 ms |
42812 KB |
Output is correct |
11 |
Correct |
1122 ms |
42812 KB |
Output is correct |
12 |
Correct |
103 ms |
42496 KB |
Output is correct |
13 |
Correct |
111 ms |
42488 KB |
Output is correct |
14 |
Correct |
119 ms |
42564 KB |
Output is correct |
15 |
Correct |
92 ms |
42864 KB |
Output is correct |
16 |
Correct |
101 ms |
42720 KB |
Output is correct |
17 |
Correct |
101 ms |
41916 KB |
Output is correct |
18 |
Correct |
104 ms |
42556 KB |
Output is correct |
19 |
Correct |
107 ms |
42500 KB |
Output is correct |
20 |
Correct |
99 ms |
42536 KB |
Output is correct |
21 |
Correct |
100 ms |
42464 KB |
Output is correct |
22 |
Correct |
113 ms |
42552 KB |
Output is correct |
23 |
Correct |
100 ms |
42428 KB |
Output is correct |
24 |
Correct |
85 ms |
42924 KB |
Output is correct |
25 |
Correct |
84 ms |
42924 KB |
Output is correct |
26 |
Correct |
91 ms |
42912 KB |
Output is correct |
27 |
Correct |
95 ms |
42924 KB |
Output is correct |
28 |
Correct |
12 ms |
21700 KB |
Output is correct |
29 |
Correct |
12 ms |
21712 KB |
Output is correct |
30 |
Correct |
12 ms |
21712 KB |
Output is correct |
31 |
Correct |
11 ms |
21700 KB |
Output is correct |
32 |
Correct |
12 ms |
21744 KB |
Output is correct |
33 |
Correct |
11 ms |
21584 KB |
Output is correct |
34 |
Correct |
12 ms |
21712 KB |
Output is correct |
35 |
Correct |
14 ms |
21668 KB |
Output is correct |
36 |
Correct |
11 ms |
21704 KB |
Output is correct |
37 |
Correct |
12 ms |
21712 KB |
Output is correct |
38 |
Correct |
12 ms |
21760 KB |
Output is correct |
39 |
Correct |
12 ms |
21684 KB |
Output is correct |
40 |
Correct |
11 ms |
21688 KB |
Output is correct |
41 |
Correct |
11 ms |
21752 KB |
Output is correct |
42 |
Correct |
12 ms |
21712 KB |
Output is correct |
43 |
Correct |
12 ms |
21712 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
21460 KB |
Output is correct |
2 |
Correct |
12 ms |
21712 KB |
Output is correct |
3 |
Correct |
12 ms |
21712 KB |
Output is correct |
4 |
Correct |
11 ms |
21712 KB |
Output is correct |
5 |
Correct |
12 ms |
21712 KB |
Output is correct |
6 |
Correct |
12 ms |
21708 KB |
Output is correct |
7 |
Correct |
14 ms |
21744 KB |
Output is correct |
8 |
Correct |
12 ms |
21712 KB |
Output is correct |
9 |
Correct |
14 ms |
21720 KB |
Output is correct |
10 |
Correct |
14 ms |
21764 KB |
Output is correct |
11 |
Correct |
12 ms |
21712 KB |
Output is correct |
12 |
Correct |
12 ms |
21328 KB |
Output is correct |
13 |
Correct |
15 ms |
21712 KB |
Output is correct |
14 |
Correct |
12 ms |
21712 KB |
Output is correct |
15 |
Correct |
13 ms |
21712 KB |
Output is correct |
16 |
Correct |
12 ms |
21712 KB |
Output is correct |
17 |
Correct |
12 ms |
21712 KB |
Output is correct |
18 |
Correct |
12 ms |
21712 KB |
Output is correct |
19 |
Correct |
11 ms |
21712 KB |
Output is correct |
20 |
Correct |
12 ms |
21696 KB |
Output is correct |
21 |
Correct |
12 ms |
21736 KB |
Output is correct |
22 |
Correct |
11 ms |
21764 KB |
Output is correct |
23 |
Correct |
12 ms |
21712 KB |
Output is correct |
24 |
Correct |
13 ms |
21776 KB |
Output is correct |
25 |
Correct |
13 ms |
21584 KB |
Output is correct |
26 |
Correct |
15 ms |
21712 KB |
Output is correct |
27 |
Correct |
14 ms |
21680 KB |
Output is correct |
28 |
Correct |
12 ms |
21744 KB |
Output is correct |
29 |
Correct |
12 ms |
21792 KB |
Output is correct |
30 |
Correct |
12 ms |
21712 KB |
Output is correct |
31 |
Correct |
11 ms |
21752 KB |
Output is correct |
32 |
Correct |
11 ms |
21712 KB |
Output is correct |
33 |
Correct |
11 ms |
21712 KB |
Output is correct |
34 |
Correct |
12 ms |
21712 KB |
Output is correct |
35 |
Correct |
11 ms |
21712 KB |
Output is correct |
36 |
Correct |
68 ms |
33804 KB |
Output is correct |
37 |
Correct |
103 ms |
42540 KB |
Output is correct |
38 |
Correct |
106 ms |
42556 KB |
Output is correct |
39 |
Correct |
113 ms |
42592 KB |
Output is correct |
40 |
Correct |
99 ms |
42540 KB |
Output is correct |
41 |
Correct |
103 ms |
42452 KB |
Output is correct |
42 |
Correct |
99 ms |
42604 KB |
Output is correct |
43 |
Correct |
89 ms |
42900 KB |
Output is correct |
44 |
Correct |
87 ms |
42896 KB |
Output is correct |
45 |
Correct |
88 ms |
42792 KB |
Output is correct |
46 |
Correct |
92 ms |
42680 KB |
Output is correct |
47 |
Correct |
117 ms |
42508 KB |
Output is correct |
48 |
Correct |
105 ms |
42540 KB |
Output is correct |
49 |
Correct |
99 ms |
42556 KB |
Output is correct |
50 |
Correct |
86 ms |
42840 KB |
Output is correct |
51 |
Correct |
86 ms |
42868 KB |
Output is correct |
52 |
Correct |
102 ms |
42540 KB |
Output is correct |
53 |
Correct |
102 ms |
42492 KB |
Output is correct |
54 |
Correct |
109 ms |
42556 KB |
Output is correct |
55 |
Correct |
106 ms |
42904 KB |
Output is correct |
56 |
Correct |
101 ms |
42708 KB |
Output is correct |
57 |
Correct |
100 ms |
41952 KB |
Output is correct |
58 |
Correct |
103 ms |
42492 KB |
Output is correct |
59 |
Correct |
110 ms |
42592 KB |
Output is correct |
60 |
Correct |
101 ms |
42464 KB |
Output is correct |
61 |
Correct |
99 ms |
42444 KB |
Output is correct |
62 |
Correct |
103 ms |
42456 KB |
Output is correct |
63 |
Correct |
104 ms |
42504 KB |
Output is correct |
64 |
Correct |
87 ms |
42936 KB |
Output is correct |
65 |
Correct |
86 ms |
42880 KB |
Output is correct |
66 |
Correct |
89 ms |
42708 KB |
Output is correct |
67 |
Correct |
95 ms |
42928 KB |
Output is correct |
68 |
Correct |
1016 ms |
42516 KB |
Output is correct |
69 |
Correct |
1472 ms |
42508 KB |
Output is correct |
70 |
Correct |
1338 ms |
42556 KB |
Output is correct |
71 |
Correct |
1151 ms |
42496 KB |
Output is correct |
72 |
Correct |
1247 ms |
42560 KB |
Output is correct |
73 |
Correct |
1077 ms |
42536 KB |
Output is correct |
74 |
Correct |
1517 ms |
42544 KB |
Output is correct |
75 |
Correct |
1062 ms |
42944 KB |
Output is correct |
76 |
Correct |
1203 ms |
42936 KB |
Output is correct |
77 |
Correct |
1152 ms |
42720 KB |
Output is correct |
78 |
Correct |
1123 ms |
42756 KB |
Output is correct |
79 |
Correct |
1101 ms |
42948 KB |
Output is correct |
80 |
Correct |
1197 ms |
42864 KB |
Output is correct |
81 |
Correct |
12 ms |
21344 KB |
Output is correct |
82 |
Correct |
14 ms |
21712 KB |
Output is correct |
83 |
Correct |
11 ms |
21712 KB |
Output is correct |
84 |
Correct |
103 ms |
42464 KB |
Output is correct |
85 |
Correct |
98 ms |
42456 KB |
Output is correct |
86 |
Correct |
105 ms |
42540 KB |
Output is correct |
87 |
Correct |
91 ms |
42924 KB |
Output is correct |
88 |
Correct |
84 ms |
42940 KB |
Output is correct |
89 |
Correct |
104 ms |
42460 KB |
Output is correct |
90 |
Correct |
100 ms |
42524 KB |
Output is correct |
91 |
Correct |
110 ms |
42496 KB |
Output is correct |
92 |
Correct |
95 ms |
42936 KB |
Output is correct |
93 |
Correct |
103 ms |
42676 KB |
Output is correct |
94 |
Correct |
13 ms |
21704 KB |
Output is correct |
95 |
Correct |
12 ms |
21712 KB |
Output is correct |
96 |
Correct |
12 ms |
21712 KB |
Output is correct |
97 |
Correct |
12 ms |
21792 KB |
Output is correct |
98 |
Correct |
12 ms |
21764 KB |
Output is correct |
99 |
Correct |
12 ms |
21712 KB |
Output is correct |
100 |
Correct |
13 ms |
21700 KB |
Output is correct |
101 |
Correct |
12 ms |
21700 KB |
Output is correct |
102 |
Correct |
12 ms |
21712 KB |
Output is correct |
103 |
Correct |
11 ms |
21712 KB |
Output is correct |
104 |
Correct |
1188 ms |
40816 KB |
Output is correct |
105 |
Correct |
1430 ms |
42524 KB |
Output is correct |
106 |
Correct |
1379 ms |
42508 KB |
Output is correct |
107 |
Correct |
1393 ms |
42536 KB |
Output is correct |
108 |
Correct |
1256 ms |
42556 KB |
Output is correct |
109 |
Correct |
1197 ms |
42528 KB |
Output is correct |
110 |
Correct |
1280 ms |
42436 KB |
Output is correct |
111 |
Correct |
879 ms |
42888 KB |
Output is correct |
112 |
Correct |
978 ms |
42920 KB |
Output is correct |
113 |
Correct |
969 ms |
42792 KB |
Output is correct |
114 |
Correct |
1053 ms |
42844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
521 ms |
33328 KB |
Output is correct |
2 |
Correct |
1086 ms |
42940 KB |
Output is correct |
3 |
Correct |
1086 ms |
42904 KB |
Output is correct |
4 |
Correct |
1055 ms |
42864 KB |
Output is correct |
5 |
Correct |
1047 ms |
42936 KB |
Output is correct |
6 |
Correct |
1198 ms |
42896 KB |
Output is correct |
7 |
Correct |
963 ms |
42924 KB |
Output is correct |
8 |
Correct |
11 ms |
21456 KB |
Output is correct |
9 |
Correct |
12 ms |
21768 KB |
Output is correct |
10 |
Correct |
12 ms |
21796 KB |
Output is correct |
11 |
Correct |
14 ms |
21460 KB |
Output is correct |
12 |
Correct |
12 ms |
21712 KB |
Output is correct |
13 |
Correct |
12 ms |
21712 KB |
Output is correct |
14 |
Correct |
11 ms |
21712 KB |
Output is correct |
15 |
Correct |
12 ms |
21712 KB |
Output is correct |
16 |
Correct |
12 ms |
21708 KB |
Output is correct |
17 |
Correct |
14 ms |
21744 KB |
Output is correct |
18 |
Correct |
12 ms |
21712 KB |
Output is correct |
19 |
Correct |
14 ms |
21720 KB |
Output is correct |
20 |
Correct |
14 ms |
21764 KB |
Output is correct |
21 |
Correct |
12 ms |
21712 KB |
Output is correct |
22 |
Correct |
12 ms |
21328 KB |
Output is correct |
23 |
Correct |
15 ms |
21712 KB |
Output is correct |
24 |
Correct |
12 ms |
21712 KB |
Output is correct |
25 |
Correct |
13 ms |
21712 KB |
Output is correct |
26 |
Correct |
12 ms |
21712 KB |
Output is correct |
27 |
Correct |
12 ms |
21712 KB |
Output is correct |
28 |
Correct |
12 ms |
21712 KB |
Output is correct |
29 |
Correct |
11 ms |
21712 KB |
Output is correct |
30 |
Correct |
12 ms |
21696 KB |
Output is correct |
31 |
Correct |
12 ms |
21736 KB |
Output is correct |
32 |
Correct |
11 ms |
21764 KB |
Output is correct |
33 |
Correct |
12 ms |
21712 KB |
Output is correct |
34 |
Correct |
13 ms |
21776 KB |
Output is correct |
35 |
Correct |
13 ms |
21584 KB |
Output is correct |
36 |
Correct |
15 ms |
21712 KB |
Output is correct |
37 |
Correct |
14 ms |
21680 KB |
Output is correct |
38 |
Correct |
12 ms |
21744 KB |
Output is correct |
39 |
Correct |
12 ms |
21792 KB |
Output is correct |
40 |
Correct |
12 ms |
21712 KB |
Output is correct |
41 |
Correct |
11 ms |
21752 KB |
Output is correct |
42 |
Correct |
11 ms |
21712 KB |
Output is correct |
43 |
Correct |
11 ms |
21712 KB |
Output is correct |
44 |
Correct |
12 ms |
21712 KB |
Output is correct |
45 |
Correct |
11 ms |
21712 KB |
Output is correct |
46 |
Correct |
68 ms |
33804 KB |
Output is correct |
47 |
Correct |
103 ms |
42540 KB |
Output is correct |
48 |
Correct |
106 ms |
42556 KB |
Output is correct |
49 |
Correct |
113 ms |
42592 KB |
Output is correct |
50 |
Correct |
99 ms |
42540 KB |
Output is correct |
51 |
Correct |
103 ms |
42452 KB |
Output is correct |
52 |
Correct |
99 ms |
42604 KB |
Output is correct |
53 |
Correct |
89 ms |
42900 KB |
Output is correct |
54 |
Correct |
87 ms |
42896 KB |
Output is correct |
55 |
Correct |
88 ms |
42792 KB |
Output is correct |
56 |
Correct |
92 ms |
42680 KB |
Output is correct |
57 |
Correct |
117 ms |
42508 KB |
Output is correct |
58 |
Correct |
105 ms |
42540 KB |
Output is correct |
59 |
Correct |
99 ms |
42556 KB |
Output is correct |
60 |
Correct |
86 ms |
42840 KB |
Output is correct |
61 |
Correct |
86 ms |
42868 KB |
Output is correct |
62 |
Correct |
102 ms |
42540 KB |
Output is correct |
63 |
Correct |
102 ms |
42492 KB |
Output is correct |
64 |
Correct |
109 ms |
42556 KB |
Output is correct |
65 |
Correct |
106 ms |
42904 KB |
Output is correct |
66 |
Correct |
101 ms |
42708 KB |
Output is correct |
67 |
Correct |
100 ms |
41952 KB |
Output is correct |
68 |
Correct |
103 ms |
42492 KB |
Output is correct |
69 |
Correct |
110 ms |
42592 KB |
Output is correct |
70 |
Correct |
101 ms |
42464 KB |
Output is correct |
71 |
Correct |
99 ms |
42444 KB |
Output is correct |
72 |
Correct |
103 ms |
42456 KB |
Output is correct |
73 |
Correct |
104 ms |
42504 KB |
Output is correct |
74 |
Correct |
87 ms |
42936 KB |
Output is correct |
75 |
Correct |
86 ms |
42880 KB |
Output is correct |
76 |
Correct |
89 ms |
42708 KB |
Output is correct |
77 |
Correct |
95 ms |
42928 KB |
Output is correct |
78 |
Correct |
1016 ms |
42516 KB |
Output is correct |
79 |
Correct |
1472 ms |
42508 KB |
Output is correct |
80 |
Correct |
1338 ms |
42556 KB |
Output is correct |
81 |
Correct |
1151 ms |
42496 KB |
Output is correct |
82 |
Correct |
1247 ms |
42560 KB |
Output is correct |
83 |
Correct |
1077 ms |
42536 KB |
Output is correct |
84 |
Correct |
1517 ms |
42544 KB |
Output is correct |
85 |
Correct |
1062 ms |
42944 KB |
Output is correct |
86 |
Correct |
1203 ms |
42936 KB |
Output is correct |
87 |
Correct |
1152 ms |
42720 KB |
Output is correct |
88 |
Correct |
1123 ms |
42756 KB |
Output is correct |
89 |
Correct |
1101 ms |
42948 KB |
Output is correct |
90 |
Correct |
1197 ms |
42864 KB |
Output is correct |
91 |
Correct |
12 ms |
21344 KB |
Output is correct |
92 |
Correct |
14 ms |
21712 KB |
Output is correct |
93 |
Correct |
11 ms |
21712 KB |
Output is correct |
94 |
Correct |
103 ms |
42464 KB |
Output is correct |
95 |
Correct |
98 ms |
42456 KB |
Output is correct |
96 |
Correct |
105 ms |
42540 KB |
Output is correct |
97 |
Correct |
91 ms |
42924 KB |
Output is correct |
98 |
Correct |
84 ms |
42940 KB |
Output is correct |
99 |
Correct |
104 ms |
42460 KB |
Output is correct |
100 |
Correct |
100 ms |
42524 KB |
Output is correct |
101 |
Correct |
110 ms |
42496 KB |
Output is correct |
102 |
Correct |
95 ms |
42936 KB |
Output is correct |
103 |
Correct |
103 ms |
42676 KB |
Output is correct |
104 |
Correct |
13 ms |
21704 KB |
Output is correct |
105 |
Correct |
12 ms |
21712 KB |
Output is correct |
106 |
Correct |
12 ms |
21712 KB |
Output is correct |
107 |
Correct |
12 ms |
21792 KB |
Output is correct |
108 |
Correct |
12 ms |
21764 KB |
Output is correct |
109 |
Correct |
12 ms |
21712 KB |
Output is correct |
110 |
Correct |
13 ms |
21700 KB |
Output is correct |
111 |
Correct |
12 ms |
21700 KB |
Output is correct |
112 |
Correct |
12 ms |
21712 KB |
Output is correct |
113 |
Correct |
11 ms |
21712 KB |
Output is correct |
114 |
Correct |
285 ms |
26364 KB |
Output is correct |
115 |
Correct |
1096 ms |
42656 KB |
Output is correct |
116 |
Correct |
1113 ms |
42448 KB |
Output is correct |
117 |
Correct |
1080 ms |
42540 KB |
Output is correct |
118 |
Correct |
1204 ms |
42448 KB |
Output is correct |
119 |
Correct |
1010 ms |
42556 KB |
Output is correct |
120 |
Correct |
1130 ms |
42512 KB |
Output is correct |
121 |
Correct |
993 ms |
42924 KB |
Output is correct |
122 |
Correct |
1046 ms |
42876 KB |
Output is correct |
123 |
Correct |
1069 ms |
42812 KB |
Output is correct |
124 |
Correct |
1122 ms |
42812 KB |
Output is correct |
125 |
Correct |
103 ms |
42496 KB |
Output is correct |
126 |
Correct |
111 ms |
42488 KB |
Output is correct |
127 |
Correct |
119 ms |
42564 KB |
Output is correct |
128 |
Correct |
92 ms |
42864 KB |
Output is correct |
129 |
Correct |
101 ms |
42720 KB |
Output is correct |
130 |
Correct |
101 ms |
41916 KB |
Output is correct |
131 |
Correct |
104 ms |
42556 KB |
Output is correct |
132 |
Correct |
107 ms |
42500 KB |
Output is correct |
133 |
Correct |
99 ms |
42536 KB |
Output is correct |
134 |
Correct |
100 ms |
42464 KB |
Output is correct |
135 |
Correct |
113 ms |
42552 KB |
Output is correct |
136 |
Correct |
100 ms |
42428 KB |
Output is correct |
137 |
Correct |
85 ms |
42924 KB |
Output is correct |
138 |
Correct |
84 ms |
42924 KB |
Output is correct |
139 |
Correct |
91 ms |
42912 KB |
Output is correct |
140 |
Correct |
95 ms |
42924 KB |
Output is correct |
141 |
Correct |
12 ms |
21700 KB |
Output is correct |
142 |
Correct |
12 ms |
21712 KB |
Output is correct |
143 |
Correct |
12 ms |
21712 KB |
Output is correct |
144 |
Correct |
11 ms |
21700 KB |
Output is correct |
145 |
Correct |
12 ms |
21744 KB |
Output is correct |
146 |
Correct |
11 ms |
21584 KB |
Output is correct |
147 |
Correct |
12 ms |
21712 KB |
Output is correct |
148 |
Correct |
14 ms |
21668 KB |
Output is correct |
149 |
Correct |
11 ms |
21704 KB |
Output is correct |
150 |
Correct |
12 ms |
21712 KB |
Output is correct |
151 |
Correct |
12 ms |
21760 KB |
Output is correct |
152 |
Correct |
12 ms |
21684 KB |
Output is correct |
153 |
Correct |
11 ms |
21688 KB |
Output is correct |
154 |
Correct |
11 ms |
21752 KB |
Output is correct |
155 |
Correct |
12 ms |
21712 KB |
Output is correct |
156 |
Correct |
12 ms |
21712 KB |
Output is correct |
157 |
Correct |
1188 ms |
40816 KB |
Output is correct |
158 |
Correct |
1430 ms |
42524 KB |
Output is correct |
159 |
Correct |
1379 ms |
42508 KB |
Output is correct |
160 |
Correct |
1393 ms |
42536 KB |
Output is correct |
161 |
Correct |
1256 ms |
42556 KB |
Output is correct |
162 |
Correct |
1197 ms |
42528 KB |
Output is correct |
163 |
Correct |
1280 ms |
42436 KB |
Output is correct |
164 |
Correct |
879 ms |
42888 KB |
Output is correct |
165 |
Correct |
978 ms |
42920 KB |
Output is correct |
166 |
Correct |
969 ms |
42792 KB |
Output is correct |
167 |
Correct |
1053 ms |
42844 KB |
Output is correct |
168 |
Correct |
10 ms |
21340 KB |
Output is correct |
169 |
Correct |
804 ms |
29004 KB |
Output is correct |
170 |
Correct |
1301 ms |
42508 KB |
Output is correct |
171 |
Correct |
1393 ms |
42524 KB |
Output is correct |
172 |
Correct |
1360 ms |
42556 KB |
Output is correct |
173 |
Correct |
1265 ms |
42556 KB |
Output is correct |
174 |
Correct |
1367 ms |
42432 KB |
Output is correct |
175 |
Correct |
1366 ms |
42472 KB |
Output is correct |
176 |
Correct |
1022 ms |
42924 KB |
Output is correct |
177 |
Correct |
1132 ms |
43068 KB |
Output is correct |
178 |
Correct |
1067 ms |
42896 KB |
Output is correct |
179 |
Correct |
983 ms |
42664 KB |
Output is correct |