#include "towers.h"
#include <vector>
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using ld = long double;
#define int ll
#define sz(x) ((int)(x).size())
using pii = pair<int,int>;
using tii = tuple<int,int,int>;
const int nmax = 2e5 + 5;
int v[nmax];
namespace DSU {
int dsu[nmax], nxt[nmax];
int mxR[nmax];
void init(int l, int r) {
for(int i = l; i <= r; i++) dsu[i] = i, nxt[i] = i + 1;
return;
}
int f(int x) { return x == dsu[x]? x : dsu[x] = f(dsu[x]); }
void unite(int x, int y) {
x = f(x);
y = f(y);
if(x == y) return;
if(x > y) swap(x, y);
dsu[y] = x;
mxR[x] = max(mxR[x], mxR[y]);
nxt[x] = nxt[y];
return;
}
int coef(int i, const vector<int>& p) {
i = f(i);
return mxR[i] - max(v[p[i]], v[p[nxt[i]]]);
}
}
int timeout[nmax];
int dir[nmax];
void initglobals(signed L, signed R) {
++L;
++R;
vector<int> p;
for(int i = L; i <= R; i++) {
if((i == L || v[i] < v[i - 1]) && (i == R || v[i] < v[i + 1])) p.emplace_back(i), timeout[i] = 1e9 + 5;
else timeout[i] = 0;
}
DSU::init(0, sz(p));
set<pii> heap;
set<int> indemnizatii;
for(int i = 0; i < sz(p) - 1; i++) {
indemnizatii.emplace(i);
indemnizatii.emplace(i + 1);
int mx = v[p[i] + 1];
for(int j = p[i] + 2; j < p[i + 1]; j++)
mx = max(mx, v[j]);
DSU::mxR[i] = mx;
heap.emplace(mx - max(v[p[i]], v[p[i + 1]]), i);
}
auto get = [&](int p_) { return pii{DSU::coef(p_, p), p_}; };
while(!heap.empty()) {
auto [C, i] = *heap.begin();
heap.erase(heap.begin());
i = DSU::f(i);
int urm = DSU::nxt[i];
if(i != *indemnizatii.begin()) {
int ant = DSU::f(i - 1);
heap.erase(heap.find(get(ant)));
}
if(urm != *indemnizatii.rbegin())
heap.erase(heap.find(get(urm)));
if(v[p[i]] < v[p[urm]]) {
timeout[p[urm]] = C;
dir[p[urm]] = p[i];
DSU::unite(i, urm);
indemnizatii.erase(urm);
if(i != *indemnizatii.begin()) {
int ant = DSU::f(i - 1);
heap.insert(get(ant));
}
if(i != *indemnizatii.rbegin())
heap.insert(get(i));
}
else {
timeout[p[i]] = C;
dir[p[i]] = p[urm];
if(i != *indemnizatii.begin()) {
int ant = DSU::f(i - 1);
DSU::unite(ant, i);
heap.insert(get(ant));
}
if(urm != *indemnizatii.rbegin())
heap.insert(get(urm));
indemnizatii.erase(i);
}
}
}
template<typename T>
struct AINT {
struct Node {
Node *l, *r;
T inner;
};
Node mem[nmax * 36];
int cnt = 0;
using ns = Node*;
int n;
ns root, nil;
int filled = 0;
void init(int n_) {
n = n_;
nil = newnode(0, 0, T());
nil -> l = nil;
nil -> r = nil;
root = nil;
root = walk([&](T& inner, int cl, int cr) {
if(cl != cr) return 1;
inner = T();
return 0;
});
}
ns newnode(ns L, ns R, T val) {
mem[cnt++] = (Node{L, R, val});
return mem + cnt - 1;
}
ns newnode() {
return newnode(nil, nil, T());
}
template<class CB> ns walk(CB&& cb) { filled ++; return root = walk(cb, 1, n); }
template<class CB> ns walk(CB&& cb, int l, int r) { return root = walk(cb, l, r, root, 1, n); }
template<class CB> ns walk(CB&& cb, int l, int r, ns node, int cl, int cr) {
if(r < cl || cr < l) return node;
auto a = node -> inner;
if(l <= cl && cr <= r && !cb(node -> inner, cl, cr)) { auto rv = newnode(node -> l, node -> r, node -> inner); node -> inner = a; return rv; }
int mid = (cl + cr) >> 1;
auto herenow = newnode();
herenow -> l = walk(cb, l, r, node -> l, cl, mid);
herenow -> r = walk(cb, l, r, node -> r, mid + 1, cr);
//cerr << cl << ' ' << cr << "\t" << herenow -> inner.val << '\t' << herenow -> l -> inner.val << '\t' << herenow -> r -> inner.val << '\n';
herenow -> inner.pull(herenow -> l -> inner, herenow -> r -> inner);
return herenow;
}
template<class CB> void const_walk(CB&& cb, ns start) const { return const_walk(cb, start, 1, n); }
template<class CB> void const_walk(CB&& cb, ns start, int l, int r) const { return const_walk(cb, l, r, start, 1, n); }
template<class CB> void const_walk(CB&& cb, int l, int r, ns node, int cl, int cr) const {
if(r < cl || cr < l) return;
if(l <= cl && cr <= r && !cb(node -> inner, cl, cr)) return;
int mid = (cl + cr) >> 1;
const_walk(cb, l, r, node -> l, cl, mid);
const_walk(cb, l, r, node -> r, mid + 1, cr);
return;
}
};
struct Sum {
int val;
Sum(int a = 0): val(a) {;}
void pull(const Sum& L, const Sum& R) { val = L.val + R.val; }
};
struct mnidx {
int val;
mnidx(int a = 0): val(a) {;}
void pull(const mnidx& L, const mnidx& R) { val = v[L.val] < v[R.val]? L.val : R.val; }
};
struct mxval {
int val;
mxval(int a = 0): val(a) {;}
void pull(const mxval& L, const mxval& R) { val = max(L.val, R.val); }
};
map<int, AINT<Sum>::ns> sumroot;
map<int, AINT<mnidx>::ns> raiseroot, fallroot;
AINT<Sum> sum_aint;
AINT<mnidx> dir_aint;
AINT<mxval> max_aint;
void init(signed N, std::vector<signed> H) {
//cerr << N << ' ' << sz(H) << '\n';
v[0] = 1e9 + 2;
for(int i = 0; i < N; i++) v[i + 1] = H[i];
initglobals(0, N - 1);
max_aint.init(N);
max_aint.walk([&](auto &a, int cl, int cr) { if(cl != cr) return 1; a.val = v[cl]; return 0; });
vector<int> idx(N); iota(all(idx), 1);
sum_aint.init(N);
sort(all(idx), [&](int a, int b) { return timeout[a] > timeout[b]; });
for(auto x : idx)
sumroot[timeout[x]] = sum_aint.walk([&](auto& a, int cl, int cr) { a.val = 1; return 0;}, x, x);
//cerr << timeout[x] << '\t' << sum_aint.root -> inner.val << '\n';
dir_aint.init(N);
sort(all(idx), [&](int a, int b) { return dir[a] < dir[b]; });
raiseroot[0] = dir_aint.root;
for(auto x : idx)
raiseroot[dir[x]] = dir_aint.walk([&](auto& a, int cl, int cr) { a.val = cl * (timeout[cl] != 0); return 0; }, x, x);
for(int i = 1; i <= N; i++) if(raiseroot.count(i) == 0) raiseroot[i] = raiseroot[i - 1];
dir_aint.init(N);
sort(all(idx), [&](int a, int b) { return dir[a] > dir[b]; });
fallroot[N + 1] = dir_aint.root;
for(auto x : idx)
fallroot[dir[x]] = dir_aint.walk([&](auto& a, int cl, int cr) { a.val = cl * (timeout[cl] != 0); return 0; }, x, x);
for(int i = N; i > 0; i--) if(fallroot.count(i) == 0) fallroot[i] = fallroot[i + 1];
return;
}
int query_max(int l, int r) {
int mx = 0;
max_aint.const_walk([&](auto& a, int cl, int cr) { mx = max(mx, a.val); return 0;}, max_aint.root, l, r);
return mx;
}
signed max_towers(signed L, signed R, signed D) {
++L, ++R;
//cerr << L << ' ' << R << '\n';
if(sumroot.lower_bound(D) == sumroot.end()) {
int mx = query_max(L, R);
return mx - max(v[L], v[R]) >= D? 2 : 1;
}
auto forsum = sumroot.lower_bound(D) -> second;
int alltogether = 0;
sum_aint.const_walk([&](auto a, int cl, int cr) { alltogether += a.val; return 0; }, forsum, L, R);
if(alltogether == 0) {
int mnL = L;
dir_aint.const_walk([&](mnidx& a, int cl, int cr) { if(v[mnL] > v[a.val]) mnL = a.val; return 0;}, raiseroot[L - 1], L , R);
int mnR = R;
dir_aint.const_walk([&](mnidx& a, int cl, int cr) { if(v[mnR] > v[a.val]) mnR = a.val; return 0;}, fallroot[R + 1], L , R);
if(mnL > mnR) return 1;
return query_max(mnL, mnR) - max(v[mnL], v[mnR]) >= D? 2 : 1;
}
int l = L, r;
sum_aint.const_walk([&](auto &a, int cl, int cr) {
if(l < cl) return 0;
if(a.val == 0) { l = cr + 1; return 0; }
if(cl == cr) { l = cl; return 0; }
return 1; }, forsum, L, R);
int rez = alltogether;
if(L < l) {
int mn = L;
dir_aint.const_walk([&](mnidx& a, int cl, int cr) { if(v[mn] > v[a.val]) mn = a.val; return 0;}, raiseroot[L - 1], L + 1, l - 1);
int mx = query_max(mn + 1, l);
if(mx - max(v[l], v[mn]) >= D) rez++;
}
int limit = alltogether - 1;
r = L;
sum_aint.const_walk([&](auto &a, int cl, int cr) {
if(r < cl) return 0;
if(a.val <= limit) { limit -= a.val; r = cr + 1; return 0; }
if(cl == cr) { r = cl; return 0; }
return 1; }, forsum, L, R);
if(r < R) {
int mn = R;
dir_aint.const_walk([&](mnidx& a, int cl, int cr) { if(v[mn] > v[a.val]) mn = a.val; return 0;}, fallroot[R + 1], r + 1, R - 1);
int mx = query_max(r + 1, mn - 1);
if(mx - max(v[r], v[mn]) >= D) rez++;
}
//cerr << L << ' ' << l << ' ' << r << ' ' << R << '\n';
return rez;
}
#undef int
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
663 ms |
517008 KB |
Output is correct |
2 |
Correct |
1297 ms |
524688 KB |
Output is correct |
3 |
Correct |
1328 ms |
524828 KB |
Output is correct |
4 |
Correct |
1397 ms |
524876 KB |
Output is correct |
5 |
Correct |
1268 ms |
524880 KB |
Output is correct |
6 |
Correct |
1303 ms |
524880 KB |
Output is correct |
7 |
Correct |
1252 ms |
524880 KB |
Output is correct |
8 |
Correct |
170 ms |
509276 KB |
Output is correct |
9 |
Correct |
176 ms |
509556 KB |
Output is correct |
10 |
Correct |
165 ms |
509520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
165 ms |
509444 KB |
Output is correct |
2 |
Correct |
173 ms |
509776 KB |
Output is correct |
3 |
Correct |
165 ms |
509776 KB |
Output is correct |
4 |
Correct |
165 ms |
509776 KB |
Output is correct |
5 |
Correct |
169 ms |
509736 KB |
Output is correct |
6 |
Correct |
192 ms |
509912 KB |
Output is correct |
7 |
Correct |
164 ms |
509776 KB |
Output is correct |
8 |
Correct |
171 ms |
509540 KB |
Output is correct |
9 |
Correct |
150 ms |
509512 KB |
Output is correct |
10 |
Correct |
189 ms |
509520 KB |
Output is correct |
11 |
Correct |
167 ms |
509520 KB |
Output is correct |
12 |
Correct |
163 ms |
509264 KB |
Output is correct |
13 |
Correct |
162 ms |
509520 KB |
Output is correct |
14 |
Correct |
190 ms |
509524 KB |
Output is correct |
15 |
Correct |
164 ms |
509776 KB |
Output is correct |
16 |
Correct |
163 ms |
509776 KB |
Output is correct |
17 |
Correct |
169 ms |
509776 KB |
Output is correct |
18 |
Correct |
161 ms |
509516 KB |
Output is correct |
19 |
Correct |
173 ms |
509608 KB |
Output is correct |
20 |
Correct |
178 ms |
509796 KB |
Output is correct |
21 |
Correct |
170 ms |
509652 KB |
Output is correct |
22 |
Correct |
173 ms |
509752 KB |
Output is correct |
23 |
Correct |
164 ms |
509520 KB |
Output is correct |
24 |
Correct |
166 ms |
509520 KB |
Output is correct |
25 |
Correct |
163 ms |
509520 KB |
Output is correct |
26 |
Correct |
165 ms |
509692 KB |
Output is correct |
27 |
Correct |
171 ms |
509648 KB |
Output is correct |
28 |
Correct |
167 ms |
509776 KB |
Output is correct |
29 |
Correct |
164 ms |
509776 KB |
Output is correct |
30 |
Correct |
174 ms |
509776 KB |
Output is correct |
31 |
Correct |
167 ms |
509808 KB |
Output is correct |
32 |
Correct |
174 ms |
509520 KB |
Output is correct |
33 |
Correct |
167 ms |
509520 KB |
Output is correct |
34 |
Correct |
177 ms |
509648 KB |
Output is correct |
35 |
Correct |
161 ms |
509552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
165 ms |
509444 KB |
Output is correct |
2 |
Correct |
173 ms |
509776 KB |
Output is correct |
3 |
Correct |
165 ms |
509776 KB |
Output is correct |
4 |
Correct |
165 ms |
509776 KB |
Output is correct |
5 |
Correct |
169 ms |
509736 KB |
Output is correct |
6 |
Correct |
192 ms |
509912 KB |
Output is correct |
7 |
Correct |
164 ms |
509776 KB |
Output is correct |
8 |
Correct |
171 ms |
509540 KB |
Output is correct |
9 |
Correct |
150 ms |
509512 KB |
Output is correct |
10 |
Correct |
189 ms |
509520 KB |
Output is correct |
11 |
Correct |
167 ms |
509520 KB |
Output is correct |
12 |
Correct |
163 ms |
509264 KB |
Output is correct |
13 |
Correct |
162 ms |
509520 KB |
Output is correct |
14 |
Correct |
190 ms |
509524 KB |
Output is correct |
15 |
Correct |
164 ms |
509776 KB |
Output is correct |
16 |
Correct |
163 ms |
509776 KB |
Output is correct |
17 |
Correct |
169 ms |
509776 KB |
Output is correct |
18 |
Correct |
161 ms |
509516 KB |
Output is correct |
19 |
Correct |
173 ms |
509608 KB |
Output is correct |
20 |
Correct |
178 ms |
509796 KB |
Output is correct |
21 |
Correct |
170 ms |
509652 KB |
Output is correct |
22 |
Correct |
173 ms |
509752 KB |
Output is correct |
23 |
Correct |
164 ms |
509520 KB |
Output is correct |
24 |
Correct |
166 ms |
509520 KB |
Output is correct |
25 |
Correct |
163 ms |
509520 KB |
Output is correct |
26 |
Correct |
165 ms |
509692 KB |
Output is correct |
27 |
Correct |
171 ms |
509648 KB |
Output is correct |
28 |
Correct |
167 ms |
509776 KB |
Output is correct |
29 |
Correct |
164 ms |
509776 KB |
Output is correct |
30 |
Correct |
174 ms |
509776 KB |
Output is correct |
31 |
Correct |
167 ms |
509808 KB |
Output is correct |
32 |
Correct |
174 ms |
509520 KB |
Output is correct |
33 |
Correct |
167 ms |
509520 KB |
Output is correct |
34 |
Correct |
177 ms |
509648 KB |
Output is correct |
35 |
Correct |
161 ms |
509552 KB |
Output is correct |
36 |
Correct |
292 ms |
521140 KB |
Output is correct |
37 |
Correct |
331 ms |
527808 KB |
Output is correct |
38 |
Correct |
375 ms |
527608 KB |
Output is correct |
39 |
Correct |
396 ms |
529212 KB |
Output is correct |
40 |
Correct |
426 ms |
529216 KB |
Output is correct |
41 |
Correct |
401 ms |
529212 KB |
Output is correct |
42 |
Correct |
396 ms |
529212 KB |
Output is correct |
43 |
Correct |
292 ms |
524880 KB |
Output is correct |
44 |
Correct |
280 ms |
524916 KB |
Output is correct |
45 |
Correct |
262 ms |
524700 KB |
Output is correct |
46 |
Correct |
286 ms |
524696 KB |
Output is correct |
47 |
Correct |
413 ms |
527556 KB |
Output is correct |
48 |
Correct |
404 ms |
529112 KB |
Output is correct |
49 |
Correct |
382 ms |
529212 KB |
Output is correct |
50 |
Correct |
275 ms |
524880 KB |
Output is correct |
51 |
Correct |
273 ms |
524692 KB |
Output is correct |
52 |
Correct |
353 ms |
527612 KB |
Output is correct |
53 |
Correct |
391 ms |
529116 KB |
Output is correct |
54 |
Correct |
394 ms |
529216 KB |
Output is correct |
55 |
Correct |
278 ms |
524844 KB |
Output is correct |
56 |
Correct |
300 ms |
524676 KB |
Output is correct |
57 |
Correct |
362 ms |
527056 KB |
Output is correct |
58 |
Correct |
347 ms |
527688 KB |
Output is correct |
59 |
Correct |
323 ms |
527548 KB |
Output is correct |
60 |
Correct |
433 ms |
529220 KB |
Output is correct |
61 |
Correct |
478 ms |
529016 KB |
Output is correct |
62 |
Correct |
406 ms |
529108 KB |
Output is correct |
63 |
Correct |
385 ms |
529032 KB |
Output is correct |
64 |
Correct |
283 ms |
524880 KB |
Output is correct |
65 |
Correct |
282 ms |
524880 KB |
Output is correct |
66 |
Correct |
291 ms |
524844 KB |
Output is correct |
67 |
Correct |
321 ms |
524876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1102 ms |
527604 KB |
Output is correct |
2 |
Correct |
1324 ms |
527556 KB |
Output is correct |
3 |
Correct |
1311 ms |
527552 KB |
Output is correct |
4 |
Correct |
1367 ms |
529212 KB |
Output is correct |
5 |
Correct |
1407 ms |
529188 KB |
Output is correct |
6 |
Correct |
1334 ms |
529212 KB |
Output is correct |
7 |
Correct |
1368 ms |
529212 KB |
Output is correct |
8 |
Correct |
1241 ms |
524880 KB |
Output is correct |
9 |
Correct |
1170 ms |
524892 KB |
Output is correct |
10 |
Correct |
1187 ms |
524828 KB |
Output is correct |
11 |
Correct |
1163 ms |
524880 KB |
Output is correct |
12 |
Correct |
1163 ms |
524836 KB |
Output is correct |
13 |
Correct |
1240 ms |
524880 KB |
Output is correct |
14 |
Correct |
147 ms |
509264 KB |
Output is correct |
15 |
Correct |
204 ms |
509520 KB |
Output is correct |
16 |
Correct |
164 ms |
509520 KB |
Output is correct |
17 |
Correct |
319 ms |
527600 KB |
Output is correct |
18 |
Correct |
452 ms |
529168 KB |
Output is correct |
19 |
Correct |
446 ms |
529216 KB |
Output is correct |
20 |
Correct |
331 ms |
524696 KB |
Output is correct |
21 |
Correct |
281 ms |
524880 KB |
Output is correct |
22 |
Correct |
383 ms |
527548 KB |
Output is correct |
23 |
Correct |
416 ms |
529184 KB |
Output is correct |
24 |
Correct |
437 ms |
529192 KB |
Output is correct |
25 |
Correct |
301 ms |
524796 KB |
Output is correct |
26 |
Correct |
291 ms |
524744 KB |
Output is correct |
27 |
Correct |
180 ms |
509652 KB |
Output is correct |
28 |
Correct |
167 ms |
509780 KB |
Output is correct |
29 |
Correct |
182 ms |
509644 KB |
Output is correct |
30 |
Correct |
184 ms |
509524 KB |
Output is correct |
31 |
Correct |
163 ms |
509584 KB |
Output is correct |
32 |
Correct |
204 ms |
509680 KB |
Output is correct |
33 |
Correct |
185 ms |
509608 KB |
Output is correct |
34 |
Correct |
184 ms |
509612 KB |
Output is correct |
35 |
Correct |
164 ms |
509520 KB |
Output is correct |
36 |
Correct |
166 ms |
509668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
428 ms |
513604 KB |
Output is correct |
2 |
Correct |
1083 ms |
527792 KB |
Output is correct |
3 |
Correct |
1099 ms |
527748 KB |
Output is correct |
4 |
Correct |
1171 ms |
529036 KB |
Output is correct |
5 |
Correct |
1219 ms |
528976 KB |
Output is correct |
6 |
Correct |
1235 ms |
529216 KB |
Output is correct |
7 |
Correct |
1152 ms |
529232 KB |
Output is correct |
8 |
Correct |
883 ms |
524880 KB |
Output is correct |
9 |
Correct |
955 ms |
524676 KB |
Output is correct |
10 |
Correct |
1002 ms |
524880 KB |
Output is correct |
11 |
Correct |
1004 ms |
524880 KB |
Output is correct |
12 |
Correct |
335 ms |
527548 KB |
Output is correct |
13 |
Correct |
382 ms |
529216 KB |
Output is correct |
14 |
Correct |
356 ms |
529216 KB |
Output is correct |
15 |
Correct |
248 ms |
524876 KB |
Output is correct |
16 |
Correct |
254 ms |
524880 KB |
Output is correct |
17 |
Correct |
337 ms |
527056 KB |
Output is correct |
18 |
Correct |
322 ms |
527580 KB |
Output is correct |
19 |
Correct |
358 ms |
527588 KB |
Output is correct |
20 |
Correct |
366 ms |
529216 KB |
Output is correct |
21 |
Correct |
365 ms |
529212 KB |
Output is correct |
22 |
Correct |
332 ms |
529192 KB |
Output is correct |
23 |
Correct |
376 ms |
529212 KB |
Output is correct |
24 |
Correct |
273 ms |
524824 KB |
Output is correct |
25 |
Correct |
258 ms |
524840 KB |
Output is correct |
26 |
Correct |
280 ms |
524880 KB |
Output is correct |
27 |
Correct |
274 ms |
524880 KB |
Output is correct |
28 |
Correct |
153 ms |
509776 KB |
Output is correct |
29 |
Correct |
159 ms |
509648 KB |
Output is correct |
30 |
Correct |
139 ms |
509776 KB |
Output is correct |
31 |
Correct |
133 ms |
509520 KB |
Output is correct |
32 |
Correct |
142 ms |
509520 KB |
Output is correct |
33 |
Correct |
139 ms |
509420 KB |
Output is correct |
34 |
Correct |
140 ms |
509776 KB |
Output is correct |
35 |
Correct |
135 ms |
509652 KB |
Output is correct |
36 |
Correct |
132 ms |
509808 KB |
Output is correct |
37 |
Correct |
173 ms |
509700 KB |
Output is correct |
38 |
Correct |
134 ms |
509828 KB |
Output is correct |
39 |
Correct |
134 ms |
509736 KB |
Output is correct |
40 |
Correct |
140 ms |
509704 KB |
Output is correct |
41 |
Correct |
146 ms |
509520 KB |
Output is correct |
42 |
Correct |
135 ms |
509520 KB |
Output is correct |
43 |
Correct |
133 ms |
509520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
165 ms |
509444 KB |
Output is correct |
2 |
Correct |
173 ms |
509776 KB |
Output is correct |
3 |
Correct |
165 ms |
509776 KB |
Output is correct |
4 |
Correct |
165 ms |
509776 KB |
Output is correct |
5 |
Correct |
169 ms |
509736 KB |
Output is correct |
6 |
Correct |
192 ms |
509912 KB |
Output is correct |
7 |
Correct |
164 ms |
509776 KB |
Output is correct |
8 |
Correct |
171 ms |
509540 KB |
Output is correct |
9 |
Correct |
150 ms |
509512 KB |
Output is correct |
10 |
Correct |
189 ms |
509520 KB |
Output is correct |
11 |
Correct |
167 ms |
509520 KB |
Output is correct |
12 |
Correct |
163 ms |
509264 KB |
Output is correct |
13 |
Correct |
162 ms |
509520 KB |
Output is correct |
14 |
Correct |
190 ms |
509524 KB |
Output is correct |
15 |
Correct |
164 ms |
509776 KB |
Output is correct |
16 |
Correct |
163 ms |
509776 KB |
Output is correct |
17 |
Correct |
169 ms |
509776 KB |
Output is correct |
18 |
Correct |
161 ms |
509516 KB |
Output is correct |
19 |
Correct |
173 ms |
509608 KB |
Output is correct |
20 |
Correct |
178 ms |
509796 KB |
Output is correct |
21 |
Correct |
170 ms |
509652 KB |
Output is correct |
22 |
Correct |
173 ms |
509752 KB |
Output is correct |
23 |
Correct |
164 ms |
509520 KB |
Output is correct |
24 |
Correct |
166 ms |
509520 KB |
Output is correct |
25 |
Correct |
163 ms |
509520 KB |
Output is correct |
26 |
Correct |
165 ms |
509692 KB |
Output is correct |
27 |
Correct |
171 ms |
509648 KB |
Output is correct |
28 |
Correct |
167 ms |
509776 KB |
Output is correct |
29 |
Correct |
164 ms |
509776 KB |
Output is correct |
30 |
Correct |
174 ms |
509776 KB |
Output is correct |
31 |
Correct |
167 ms |
509808 KB |
Output is correct |
32 |
Correct |
174 ms |
509520 KB |
Output is correct |
33 |
Correct |
167 ms |
509520 KB |
Output is correct |
34 |
Correct |
177 ms |
509648 KB |
Output is correct |
35 |
Correct |
161 ms |
509552 KB |
Output is correct |
36 |
Correct |
292 ms |
521140 KB |
Output is correct |
37 |
Correct |
331 ms |
527808 KB |
Output is correct |
38 |
Correct |
375 ms |
527608 KB |
Output is correct |
39 |
Correct |
396 ms |
529212 KB |
Output is correct |
40 |
Correct |
426 ms |
529216 KB |
Output is correct |
41 |
Correct |
401 ms |
529212 KB |
Output is correct |
42 |
Correct |
396 ms |
529212 KB |
Output is correct |
43 |
Correct |
292 ms |
524880 KB |
Output is correct |
44 |
Correct |
280 ms |
524916 KB |
Output is correct |
45 |
Correct |
262 ms |
524700 KB |
Output is correct |
46 |
Correct |
286 ms |
524696 KB |
Output is correct |
47 |
Correct |
413 ms |
527556 KB |
Output is correct |
48 |
Correct |
404 ms |
529112 KB |
Output is correct |
49 |
Correct |
382 ms |
529212 KB |
Output is correct |
50 |
Correct |
275 ms |
524880 KB |
Output is correct |
51 |
Correct |
273 ms |
524692 KB |
Output is correct |
52 |
Correct |
353 ms |
527612 KB |
Output is correct |
53 |
Correct |
391 ms |
529116 KB |
Output is correct |
54 |
Correct |
394 ms |
529216 KB |
Output is correct |
55 |
Correct |
278 ms |
524844 KB |
Output is correct |
56 |
Correct |
300 ms |
524676 KB |
Output is correct |
57 |
Correct |
362 ms |
527056 KB |
Output is correct |
58 |
Correct |
347 ms |
527688 KB |
Output is correct |
59 |
Correct |
323 ms |
527548 KB |
Output is correct |
60 |
Correct |
433 ms |
529220 KB |
Output is correct |
61 |
Correct |
478 ms |
529016 KB |
Output is correct |
62 |
Correct |
406 ms |
529108 KB |
Output is correct |
63 |
Correct |
385 ms |
529032 KB |
Output is correct |
64 |
Correct |
283 ms |
524880 KB |
Output is correct |
65 |
Correct |
282 ms |
524880 KB |
Output is correct |
66 |
Correct |
291 ms |
524844 KB |
Output is correct |
67 |
Correct |
321 ms |
524876 KB |
Output is correct |
68 |
Correct |
1102 ms |
527604 KB |
Output is correct |
69 |
Correct |
1324 ms |
527556 KB |
Output is correct |
70 |
Correct |
1311 ms |
527552 KB |
Output is correct |
71 |
Correct |
1367 ms |
529212 KB |
Output is correct |
72 |
Correct |
1407 ms |
529188 KB |
Output is correct |
73 |
Correct |
1334 ms |
529212 KB |
Output is correct |
74 |
Correct |
1368 ms |
529212 KB |
Output is correct |
75 |
Correct |
1241 ms |
524880 KB |
Output is correct |
76 |
Correct |
1170 ms |
524892 KB |
Output is correct |
77 |
Correct |
1187 ms |
524828 KB |
Output is correct |
78 |
Correct |
1163 ms |
524880 KB |
Output is correct |
79 |
Correct |
1163 ms |
524836 KB |
Output is correct |
80 |
Correct |
1240 ms |
524880 KB |
Output is correct |
81 |
Correct |
147 ms |
509264 KB |
Output is correct |
82 |
Correct |
204 ms |
509520 KB |
Output is correct |
83 |
Correct |
164 ms |
509520 KB |
Output is correct |
84 |
Correct |
319 ms |
527600 KB |
Output is correct |
85 |
Correct |
452 ms |
529168 KB |
Output is correct |
86 |
Correct |
446 ms |
529216 KB |
Output is correct |
87 |
Correct |
331 ms |
524696 KB |
Output is correct |
88 |
Correct |
281 ms |
524880 KB |
Output is correct |
89 |
Correct |
383 ms |
527548 KB |
Output is correct |
90 |
Correct |
416 ms |
529184 KB |
Output is correct |
91 |
Correct |
437 ms |
529192 KB |
Output is correct |
92 |
Correct |
301 ms |
524796 KB |
Output is correct |
93 |
Correct |
291 ms |
524744 KB |
Output is correct |
94 |
Correct |
180 ms |
509652 KB |
Output is correct |
95 |
Correct |
167 ms |
509780 KB |
Output is correct |
96 |
Correct |
182 ms |
509644 KB |
Output is correct |
97 |
Correct |
184 ms |
509524 KB |
Output is correct |
98 |
Correct |
163 ms |
509584 KB |
Output is correct |
99 |
Correct |
204 ms |
509680 KB |
Output is correct |
100 |
Correct |
185 ms |
509608 KB |
Output is correct |
101 |
Correct |
184 ms |
509612 KB |
Output is correct |
102 |
Correct |
164 ms |
509520 KB |
Output is correct |
103 |
Correct |
166 ms |
509668 KB |
Output is correct |
104 |
Correct |
1065 ms |
525540 KB |
Output is correct |
105 |
Correct |
1352 ms |
527744 KB |
Output is correct |
106 |
Correct |
1386 ms |
527572 KB |
Output is correct |
107 |
Correct |
1361 ms |
529052 KB |
Output is correct |
108 |
Correct |
1465 ms |
529212 KB |
Output is correct |
109 |
Correct |
1266 ms |
529216 KB |
Output is correct |
110 |
Correct |
1258 ms |
529068 KB |
Output is correct |
111 |
Correct |
1236 ms |
524848 KB |
Output is correct |
112 |
Correct |
1263 ms |
524828 KB |
Output is correct |
113 |
Correct |
1317 ms |
524880 KB |
Output is correct |
114 |
Correct |
1283 ms |
524828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
663 ms |
517008 KB |
Output is correct |
2 |
Correct |
1297 ms |
524688 KB |
Output is correct |
3 |
Correct |
1328 ms |
524828 KB |
Output is correct |
4 |
Correct |
1397 ms |
524876 KB |
Output is correct |
5 |
Correct |
1268 ms |
524880 KB |
Output is correct |
6 |
Correct |
1303 ms |
524880 KB |
Output is correct |
7 |
Correct |
1252 ms |
524880 KB |
Output is correct |
8 |
Correct |
170 ms |
509276 KB |
Output is correct |
9 |
Correct |
176 ms |
509556 KB |
Output is correct |
10 |
Correct |
165 ms |
509520 KB |
Output is correct |
11 |
Correct |
165 ms |
509444 KB |
Output is correct |
12 |
Correct |
173 ms |
509776 KB |
Output is correct |
13 |
Correct |
165 ms |
509776 KB |
Output is correct |
14 |
Correct |
165 ms |
509776 KB |
Output is correct |
15 |
Correct |
169 ms |
509736 KB |
Output is correct |
16 |
Correct |
192 ms |
509912 KB |
Output is correct |
17 |
Correct |
164 ms |
509776 KB |
Output is correct |
18 |
Correct |
171 ms |
509540 KB |
Output is correct |
19 |
Correct |
150 ms |
509512 KB |
Output is correct |
20 |
Correct |
189 ms |
509520 KB |
Output is correct |
21 |
Correct |
167 ms |
509520 KB |
Output is correct |
22 |
Correct |
163 ms |
509264 KB |
Output is correct |
23 |
Correct |
162 ms |
509520 KB |
Output is correct |
24 |
Correct |
190 ms |
509524 KB |
Output is correct |
25 |
Correct |
164 ms |
509776 KB |
Output is correct |
26 |
Correct |
163 ms |
509776 KB |
Output is correct |
27 |
Correct |
169 ms |
509776 KB |
Output is correct |
28 |
Correct |
161 ms |
509516 KB |
Output is correct |
29 |
Correct |
173 ms |
509608 KB |
Output is correct |
30 |
Correct |
178 ms |
509796 KB |
Output is correct |
31 |
Correct |
170 ms |
509652 KB |
Output is correct |
32 |
Correct |
173 ms |
509752 KB |
Output is correct |
33 |
Correct |
164 ms |
509520 KB |
Output is correct |
34 |
Correct |
166 ms |
509520 KB |
Output is correct |
35 |
Correct |
163 ms |
509520 KB |
Output is correct |
36 |
Correct |
165 ms |
509692 KB |
Output is correct |
37 |
Correct |
171 ms |
509648 KB |
Output is correct |
38 |
Correct |
167 ms |
509776 KB |
Output is correct |
39 |
Correct |
164 ms |
509776 KB |
Output is correct |
40 |
Correct |
174 ms |
509776 KB |
Output is correct |
41 |
Correct |
167 ms |
509808 KB |
Output is correct |
42 |
Correct |
174 ms |
509520 KB |
Output is correct |
43 |
Correct |
167 ms |
509520 KB |
Output is correct |
44 |
Correct |
177 ms |
509648 KB |
Output is correct |
45 |
Correct |
161 ms |
509552 KB |
Output is correct |
46 |
Correct |
292 ms |
521140 KB |
Output is correct |
47 |
Correct |
331 ms |
527808 KB |
Output is correct |
48 |
Correct |
375 ms |
527608 KB |
Output is correct |
49 |
Correct |
396 ms |
529212 KB |
Output is correct |
50 |
Correct |
426 ms |
529216 KB |
Output is correct |
51 |
Correct |
401 ms |
529212 KB |
Output is correct |
52 |
Correct |
396 ms |
529212 KB |
Output is correct |
53 |
Correct |
292 ms |
524880 KB |
Output is correct |
54 |
Correct |
280 ms |
524916 KB |
Output is correct |
55 |
Correct |
262 ms |
524700 KB |
Output is correct |
56 |
Correct |
286 ms |
524696 KB |
Output is correct |
57 |
Correct |
413 ms |
527556 KB |
Output is correct |
58 |
Correct |
404 ms |
529112 KB |
Output is correct |
59 |
Correct |
382 ms |
529212 KB |
Output is correct |
60 |
Correct |
275 ms |
524880 KB |
Output is correct |
61 |
Correct |
273 ms |
524692 KB |
Output is correct |
62 |
Correct |
353 ms |
527612 KB |
Output is correct |
63 |
Correct |
391 ms |
529116 KB |
Output is correct |
64 |
Correct |
394 ms |
529216 KB |
Output is correct |
65 |
Correct |
278 ms |
524844 KB |
Output is correct |
66 |
Correct |
300 ms |
524676 KB |
Output is correct |
67 |
Correct |
362 ms |
527056 KB |
Output is correct |
68 |
Correct |
347 ms |
527688 KB |
Output is correct |
69 |
Correct |
323 ms |
527548 KB |
Output is correct |
70 |
Correct |
433 ms |
529220 KB |
Output is correct |
71 |
Correct |
478 ms |
529016 KB |
Output is correct |
72 |
Correct |
406 ms |
529108 KB |
Output is correct |
73 |
Correct |
385 ms |
529032 KB |
Output is correct |
74 |
Correct |
283 ms |
524880 KB |
Output is correct |
75 |
Correct |
282 ms |
524880 KB |
Output is correct |
76 |
Correct |
291 ms |
524844 KB |
Output is correct |
77 |
Correct |
321 ms |
524876 KB |
Output is correct |
78 |
Correct |
1102 ms |
527604 KB |
Output is correct |
79 |
Correct |
1324 ms |
527556 KB |
Output is correct |
80 |
Correct |
1311 ms |
527552 KB |
Output is correct |
81 |
Correct |
1367 ms |
529212 KB |
Output is correct |
82 |
Correct |
1407 ms |
529188 KB |
Output is correct |
83 |
Correct |
1334 ms |
529212 KB |
Output is correct |
84 |
Correct |
1368 ms |
529212 KB |
Output is correct |
85 |
Correct |
1241 ms |
524880 KB |
Output is correct |
86 |
Correct |
1170 ms |
524892 KB |
Output is correct |
87 |
Correct |
1187 ms |
524828 KB |
Output is correct |
88 |
Correct |
1163 ms |
524880 KB |
Output is correct |
89 |
Correct |
1163 ms |
524836 KB |
Output is correct |
90 |
Correct |
1240 ms |
524880 KB |
Output is correct |
91 |
Correct |
147 ms |
509264 KB |
Output is correct |
92 |
Correct |
204 ms |
509520 KB |
Output is correct |
93 |
Correct |
164 ms |
509520 KB |
Output is correct |
94 |
Correct |
319 ms |
527600 KB |
Output is correct |
95 |
Correct |
452 ms |
529168 KB |
Output is correct |
96 |
Correct |
446 ms |
529216 KB |
Output is correct |
97 |
Correct |
331 ms |
524696 KB |
Output is correct |
98 |
Correct |
281 ms |
524880 KB |
Output is correct |
99 |
Correct |
383 ms |
527548 KB |
Output is correct |
100 |
Correct |
416 ms |
529184 KB |
Output is correct |
101 |
Correct |
437 ms |
529192 KB |
Output is correct |
102 |
Correct |
301 ms |
524796 KB |
Output is correct |
103 |
Correct |
291 ms |
524744 KB |
Output is correct |
104 |
Correct |
180 ms |
509652 KB |
Output is correct |
105 |
Correct |
167 ms |
509780 KB |
Output is correct |
106 |
Correct |
182 ms |
509644 KB |
Output is correct |
107 |
Correct |
184 ms |
509524 KB |
Output is correct |
108 |
Correct |
163 ms |
509584 KB |
Output is correct |
109 |
Correct |
204 ms |
509680 KB |
Output is correct |
110 |
Correct |
185 ms |
509608 KB |
Output is correct |
111 |
Correct |
184 ms |
509612 KB |
Output is correct |
112 |
Correct |
164 ms |
509520 KB |
Output is correct |
113 |
Correct |
166 ms |
509668 KB |
Output is correct |
114 |
Correct |
428 ms |
513604 KB |
Output is correct |
115 |
Correct |
1083 ms |
527792 KB |
Output is correct |
116 |
Correct |
1099 ms |
527748 KB |
Output is correct |
117 |
Correct |
1171 ms |
529036 KB |
Output is correct |
118 |
Correct |
1219 ms |
528976 KB |
Output is correct |
119 |
Correct |
1235 ms |
529216 KB |
Output is correct |
120 |
Correct |
1152 ms |
529232 KB |
Output is correct |
121 |
Correct |
883 ms |
524880 KB |
Output is correct |
122 |
Correct |
955 ms |
524676 KB |
Output is correct |
123 |
Correct |
1002 ms |
524880 KB |
Output is correct |
124 |
Correct |
1004 ms |
524880 KB |
Output is correct |
125 |
Correct |
335 ms |
527548 KB |
Output is correct |
126 |
Correct |
382 ms |
529216 KB |
Output is correct |
127 |
Correct |
356 ms |
529216 KB |
Output is correct |
128 |
Correct |
248 ms |
524876 KB |
Output is correct |
129 |
Correct |
254 ms |
524880 KB |
Output is correct |
130 |
Correct |
337 ms |
527056 KB |
Output is correct |
131 |
Correct |
322 ms |
527580 KB |
Output is correct |
132 |
Correct |
358 ms |
527588 KB |
Output is correct |
133 |
Correct |
366 ms |
529216 KB |
Output is correct |
134 |
Correct |
365 ms |
529212 KB |
Output is correct |
135 |
Correct |
332 ms |
529192 KB |
Output is correct |
136 |
Correct |
376 ms |
529212 KB |
Output is correct |
137 |
Correct |
273 ms |
524824 KB |
Output is correct |
138 |
Correct |
258 ms |
524840 KB |
Output is correct |
139 |
Correct |
280 ms |
524880 KB |
Output is correct |
140 |
Correct |
274 ms |
524880 KB |
Output is correct |
141 |
Correct |
153 ms |
509776 KB |
Output is correct |
142 |
Correct |
159 ms |
509648 KB |
Output is correct |
143 |
Correct |
139 ms |
509776 KB |
Output is correct |
144 |
Correct |
133 ms |
509520 KB |
Output is correct |
145 |
Correct |
142 ms |
509520 KB |
Output is correct |
146 |
Correct |
139 ms |
509420 KB |
Output is correct |
147 |
Correct |
140 ms |
509776 KB |
Output is correct |
148 |
Correct |
135 ms |
509652 KB |
Output is correct |
149 |
Correct |
132 ms |
509808 KB |
Output is correct |
150 |
Correct |
173 ms |
509700 KB |
Output is correct |
151 |
Correct |
134 ms |
509828 KB |
Output is correct |
152 |
Correct |
134 ms |
509736 KB |
Output is correct |
153 |
Correct |
140 ms |
509704 KB |
Output is correct |
154 |
Correct |
146 ms |
509520 KB |
Output is correct |
155 |
Correct |
135 ms |
509520 KB |
Output is correct |
156 |
Correct |
133 ms |
509520 KB |
Output is correct |
157 |
Correct |
1065 ms |
525540 KB |
Output is correct |
158 |
Correct |
1352 ms |
527744 KB |
Output is correct |
159 |
Correct |
1386 ms |
527572 KB |
Output is correct |
160 |
Correct |
1361 ms |
529052 KB |
Output is correct |
161 |
Correct |
1465 ms |
529212 KB |
Output is correct |
162 |
Correct |
1266 ms |
529216 KB |
Output is correct |
163 |
Correct |
1258 ms |
529068 KB |
Output is correct |
164 |
Correct |
1236 ms |
524848 KB |
Output is correct |
165 |
Correct |
1263 ms |
524828 KB |
Output is correct |
166 |
Correct |
1317 ms |
524880 KB |
Output is correct |
167 |
Correct |
1283 ms |
524828 KB |
Output is correct |
168 |
Correct |
147 ms |
509264 KB |
Output is correct |
169 |
Correct |
786 ms |
515572 KB |
Output is correct |
170 |
Correct |
1511 ms |
527552 KB |
Output is correct |
171 |
Correct |
1545 ms |
527556 KB |
Output is correct |
172 |
Correct |
1601 ms |
529052 KB |
Output is correct |
173 |
Correct |
1478 ms |
529024 KB |
Output is correct |
174 |
Correct |
1462 ms |
529128 KB |
Output is correct |
175 |
Correct |
1527 ms |
529216 KB |
Output is correct |
176 |
Correct |
1227 ms |
524876 KB |
Output is correct |
177 |
Correct |
1176 ms |
524876 KB |
Output is correct |
178 |
Correct |
1259 ms |
524880 KB |
Output is correct |
179 |
Correct |
1337 ms |
524788 KB |
Output is correct |