#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;
};
using ns = Node*;
Node mem[nmax * 32];
int cnt = 0;
int n;
ns nil, root;
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()); }
void init(int n_) {
n = n_;
nil = newnode(nil, nil, T()); nil -> l = nil -> r = nil; nil -> inner = T();
root = nil;
walk([&](T& a, int cl, int cr) {
if(cl != cr) return 1;
a = T();
return 0;
});
}
template<class CB> ns walk(CB&& cb) { return root = walk<0>(cb, root, 1, n); }
template<class CB> ns walk(CB&& cb, int l, int r) { return root = walk<0>(cb, root, l, r); }
template<class CB> void const_walk(CB&& cb, ns start) { const_walk(cb, start, 1, n); }
template<class CB> void const_walk(CB&& cb, ns start, int l, int r) { walk<1>(cb, l, r, start, 1, n); }
template<int cst = 0, class CB> ns walk(CB&& cb, ns start, int l, int r) { return walk<cst>(cb, l, r, start, 1, n); }
template<int cst, class CB> ns walk(CB&& cb, int l, int r, ns node, int cl, int cr) {
if(cr < l || r < cl) return node;
auto a = node -> inner;
if(l <= cl && cr <= r && !cb(a, cl, cr)) {
if(cst) return node;
return newnode(node -> l, node -> r, a);
}
int mid = (cl + cr) >> 1;
auto L = walk<cst>(cb, l, r, node -> l, cl, mid);
auto R = walk<cst>(cb, l, r, node -> r, mid + 1, cr);
if(!cst) node = newnode();
node -> l = L, node -> r = R, node -> inner.pull(L -> inner, R -> inner);
return node;
}
};
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);
//cerr << sum_aint.root -> inner.val << '\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;
if(sumroot.lower_bound(D) == sumroot.end()) {
JOEVER:
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 alltogether = 0;
auto forsum = sumroot.lower_bound(D) -> second;
sum_aint.const_walk([&](auto a, int cl, int cr) { alltogether += a.val; return 0; }, forsum, L, R);
if(alltogether == 0) {
goto JOEVER;
}
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
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1018 ms |
461136 KB |
Output is correct |
2 |
Correct |
1841 ms |
467492 KB |
Output is correct |
3 |
Correct |
1652 ms |
467568 KB |
Output is correct |
4 |
Correct |
1474 ms |
467536 KB |
Output is correct |
5 |
Correct |
1438 ms |
467480 KB |
Output is correct |
6 |
Correct |
1494 ms |
467536 KB |
Output is correct |
7 |
Correct |
1376 ms |
467536 KB |
Output is correct |
8 |
Correct |
146 ms |
451992 KB |
Output is correct |
9 |
Correct |
156 ms |
452292 KB |
Output is correct |
10 |
Correct |
159 ms |
452260 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
150 ms |
451976 KB |
Output is correct |
2 |
Correct |
152 ms |
452172 KB |
Output is correct |
3 |
Correct |
158 ms |
452176 KB |
Output is correct |
4 |
Correct |
157 ms |
452340 KB |
Output is correct |
5 |
Correct |
142 ms |
452176 KB |
Output is correct |
6 |
Correct |
148 ms |
452284 KB |
Output is correct |
7 |
Correct |
154 ms |
452368 KB |
Output is correct |
8 |
Correct |
155 ms |
452060 KB |
Output is correct |
9 |
Correct |
155 ms |
452180 KB |
Output is correct |
10 |
Correct |
150 ms |
452172 KB |
Output is correct |
11 |
Correct |
154 ms |
452176 KB |
Output is correct |
12 |
Correct |
169 ms |
451960 KB |
Output is correct |
13 |
Correct |
147 ms |
452284 KB |
Output is correct |
14 |
Correct |
182 ms |
452196 KB |
Output is correct |
15 |
Correct |
155 ms |
452176 KB |
Output is correct |
16 |
Correct |
148 ms |
452176 KB |
Output is correct |
17 |
Correct |
169 ms |
452224 KB |
Output is correct |
18 |
Correct |
167 ms |
452260 KB |
Output is correct |
19 |
Correct |
152 ms |
452172 KB |
Output is correct |
20 |
Correct |
144 ms |
452176 KB |
Output is correct |
21 |
Correct |
136 ms |
452252 KB |
Output is correct |
22 |
Correct |
164 ms |
452408 KB |
Output is correct |
23 |
Correct |
143 ms |
452176 KB |
Output is correct |
24 |
Correct |
150 ms |
452176 KB |
Output is correct |
25 |
Correct |
144 ms |
452176 KB |
Output is correct |
26 |
Correct |
138 ms |
452176 KB |
Output is correct |
27 |
Correct |
147 ms |
452176 KB |
Output is correct |
28 |
Correct |
152 ms |
452232 KB |
Output is correct |
29 |
Correct |
142 ms |
452176 KB |
Output is correct |
30 |
Correct |
161 ms |
452376 KB |
Output is correct |
31 |
Correct |
141 ms |
452176 KB |
Output is correct |
32 |
Correct |
159 ms |
452176 KB |
Output is correct |
33 |
Correct |
146 ms |
452140 KB |
Output is correct |
34 |
Correct |
144 ms |
452180 KB |
Output is correct |
35 |
Correct |
145 ms |
452172 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
150 ms |
451976 KB |
Output is correct |
2 |
Correct |
152 ms |
452172 KB |
Output is correct |
3 |
Correct |
158 ms |
452176 KB |
Output is correct |
4 |
Correct |
157 ms |
452340 KB |
Output is correct |
5 |
Correct |
142 ms |
452176 KB |
Output is correct |
6 |
Correct |
148 ms |
452284 KB |
Output is correct |
7 |
Correct |
154 ms |
452368 KB |
Output is correct |
8 |
Correct |
155 ms |
452060 KB |
Output is correct |
9 |
Correct |
155 ms |
452180 KB |
Output is correct |
10 |
Correct |
150 ms |
452172 KB |
Output is correct |
11 |
Correct |
154 ms |
452176 KB |
Output is correct |
12 |
Correct |
169 ms |
451960 KB |
Output is correct |
13 |
Correct |
147 ms |
452284 KB |
Output is correct |
14 |
Correct |
182 ms |
452196 KB |
Output is correct |
15 |
Correct |
155 ms |
452176 KB |
Output is correct |
16 |
Correct |
148 ms |
452176 KB |
Output is correct |
17 |
Correct |
169 ms |
452224 KB |
Output is correct |
18 |
Correct |
167 ms |
452260 KB |
Output is correct |
19 |
Correct |
152 ms |
452172 KB |
Output is correct |
20 |
Correct |
144 ms |
452176 KB |
Output is correct |
21 |
Correct |
136 ms |
452252 KB |
Output is correct |
22 |
Correct |
164 ms |
452408 KB |
Output is correct |
23 |
Correct |
143 ms |
452176 KB |
Output is correct |
24 |
Correct |
150 ms |
452176 KB |
Output is correct |
25 |
Correct |
144 ms |
452176 KB |
Output is correct |
26 |
Correct |
138 ms |
452176 KB |
Output is correct |
27 |
Correct |
147 ms |
452176 KB |
Output is correct |
28 |
Correct |
152 ms |
452232 KB |
Output is correct |
29 |
Correct |
142 ms |
452176 KB |
Output is correct |
30 |
Correct |
161 ms |
452376 KB |
Output is correct |
31 |
Correct |
141 ms |
452176 KB |
Output is correct |
32 |
Correct |
159 ms |
452176 KB |
Output is correct |
33 |
Correct |
146 ms |
452140 KB |
Output is correct |
34 |
Correct |
144 ms |
452180 KB |
Output is correct |
35 |
Correct |
145 ms |
452172 KB |
Output is correct |
36 |
Correct |
257 ms |
463908 KB |
Output is correct |
37 |
Correct |
333 ms |
470516 KB |
Output is correct |
38 |
Correct |
365 ms |
470464 KB |
Output is correct |
39 |
Correct |
365 ms |
472008 KB |
Output is correct |
40 |
Correct |
420 ms |
471888 KB |
Output is correct |
41 |
Correct |
369 ms |
471868 KB |
Output is correct |
42 |
Correct |
395 ms |
471972 KB |
Output is correct |
43 |
Correct |
266 ms |
467540 KB |
Output is correct |
44 |
Correct |
295 ms |
467536 KB |
Output is correct |
45 |
Correct |
267 ms |
467536 KB |
Output is correct |
46 |
Correct |
269 ms |
467588 KB |
Output is correct |
47 |
Correct |
343 ms |
470452 KB |
Output is correct |
48 |
Correct |
433 ms |
472064 KB |
Output is correct |
49 |
Correct |
396 ms |
471872 KB |
Output is correct |
50 |
Correct |
274 ms |
467536 KB |
Output is correct |
51 |
Correct |
290 ms |
467540 KB |
Output is correct |
52 |
Correct |
358 ms |
470464 KB |
Output is correct |
53 |
Correct |
363 ms |
471872 KB |
Output is correct |
54 |
Correct |
395 ms |
472016 KB |
Output is correct |
55 |
Correct |
271 ms |
467536 KB |
Output is correct |
56 |
Correct |
282 ms |
467536 KB |
Output is correct |
57 |
Correct |
326 ms |
469804 KB |
Output is correct |
58 |
Correct |
356 ms |
470480 KB |
Output is correct |
59 |
Correct |
347 ms |
470464 KB |
Output is correct |
60 |
Correct |
393 ms |
471848 KB |
Output is correct |
61 |
Correct |
395 ms |
471892 KB |
Output is correct |
62 |
Correct |
395 ms |
472024 KB |
Output is correct |
63 |
Correct |
385 ms |
472128 KB |
Output is correct |
64 |
Correct |
264 ms |
467532 KB |
Output is correct |
65 |
Correct |
260 ms |
467536 KB |
Output is correct |
66 |
Correct |
258 ms |
467536 KB |
Output is correct |
67 |
Correct |
272 ms |
467456 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1213 ms |
470468 KB |
Output is correct |
2 |
Correct |
1542 ms |
470568 KB |
Output is correct |
3 |
Correct |
1482 ms |
470464 KB |
Output is correct |
4 |
Correct |
1621 ms |
471892 KB |
Output is correct |
5 |
Correct |
1473 ms |
472084 KB |
Output is correct |
6 |
Correct |
1406 ms |
471924 KB |
Output is correct |
7 |
Correct |
1536 ms |
472172 KB |
Output is correct |
8 |
Correct |
1532 ms |
467676 KB |
Output is correct |
9 |
Correct |
1432 ms |
467532 KB |
Output is correct |
10 |
Correct |
1366 ms |
467536 KB |
Output is correct |
11 |
Correct |
1389 ms |
467508 KB |
Output is correct |
12 |
Correct |
1372 ms |
467536 KB |
Output is correct |
13 |
Correct |
1368 ms |
467536 KB |
Output is correct |
14 |
Correct |
157 ms |
451920 KB |
Output is correct |
15 |
Correct |
153 ms |
452176 KB |
Output is correct |
16 |
Correct |
153 ms |
452172 KB |
Output is correct |
17 |
Correct |
346 ms |
470540 KB |
Output is correct |
18 |
Correct |
385 ms |
471888 KB |
Output is correct |
19 |
Correct |
361 ms |
471864 KB |
Output is correct |
20 |
Correct |
260 ms |
467620 KB |
Output is correct |
21 |
Correct |
255 ms |
467536 KB |
Output is correct |
22 |
Correct |
348 ms |
470460 KB |
Output is correct |
23 |
Correct |
424 ms |
471928 KB |
Output is correct |
24 |
Correct |
388 ms |
471868 KB |
Output is correct |
25 |
Correct |
275 ms |
467560 KB |
Output is correct |
26 |
Correct |
262 ms |
467536 KB |
Output is correct |
27 |
Correct |
154 ms |
452268 KB |
Output is correct |
28 |
Correct |
154 ms |
452236 KB |
Output is correct |
29 |
Correct |
155 ms |
452176 KB |
Output is correct |
30 |
Correct |
148 ms |
452176 KB |
Output is correct |
31 |
Correct |
154 ms |
452140 KB |
Output is correct |
32 |
Correct |
145 ms |
452380 KB |
Output is correct |
33 |
Correct |
147 ms |
452168 KB |
Output is correct |
34 |
Correct |
150 ms |
452396 KB |
Output is correct |
35 |
Correct |
146 ms |
452176 KB |
Output is correct |
36 |
Correct |
146 ms |
452128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
446 ms |
456320 KB |
Output is correct |
2 |
Correct |
1100 ms |
470536 KB |
Output is correct |
3 |
Correct |
1204 ms |
470436 KB |
Output is correct |
4 |
Correct |
1148 ms |
472068 KB |
Output is correct |
5 |
Correct |
1204 ms |
471928 KB |
Output is correct |
6 |
Correct |
1136 ms |
471884 KB |
Output is correct |
7 |
Correct |
1113 ms |
471868 KB |
Output is correct |
8 |
Correct |
975 ms |
467536 KB |
Output is correct |
9 |
Correct |
982 ms |
467536 KB |
Output is correct |
10 |
Correct |
952 ms |
467536 KB |
Output is correct |
11 |
Correct |
982 ms |
467560 KB |
Output is correct |
12 |
Correct |
318 ms |
470464 KB |
Output is correct |
13 |
Correct |
351 ms |
471904 KB |
Output is correct |
14 |
Correct |
358 ms |
472012 KB |
Output is correct |
15 |
Correct |
283 ms |
467536 KB |
Output is correct |
16 |
Correct |
241 ms |
467536 KB |
Output is correct |
17 |
Correct |
314 ms |
469932 KB |
Output is correct |
18 |
Correct |
340 ms |
470468 KB |
Output is correct |
19 |
Correct |
372 ms |
470464 KB |
Output is correct |
20 |
Correct |
362 ms |
471916 KB |
Output is correct |
21 |
Correct |
413 ms |
471952 KB |
Output is correct |
22 |
Correct |
429 ms |
471868 KB |
Output is correct |
23 |
Correct |
405 ms |
471968 KB |
Output is correct |
24 |
Correct |
284 ms |
466768 KB |
Output is correct |
25 |
Correct |
266 ms |
466940 KB |
Output is correct |
26 |
Correct |
287 ms |
467024 KB |
Output is correct |
27 |
Correct |
313 ms |
467024 KB |
Output is correct |
28 |
Correct |
159 ms |
451664 KB |
Output is correct |
29 |
Correct |
144 ms |
451712 KB |
Output is correct |
30 |
Correct |
155 ms |
452176 KB |
Output is correct |
31 |
Correct |
142 ms |
452176 KB |
Output is correct |
32 |
Correct |
139 ms |
452144 KB |
Output is correct |
33 |
Correct |
173 ms |
452180 KB |
Output is correct |
34 |
Correct |
143 ms |
452212 KB |
Output is correct |
35 |
Correct |
195 ms |
452180 KB |
Output is correct |
36 |
Correct |
145 ms |
452200 KB |
Output is correct |
37 |
Correct |
148 ms |
452176 KB |
Output is correct |
38 |
Correct |
142 ms |
452240 KB |
Output is correct |
39 |
Correct |
152 ms |
452324 KB |
Output is correct |
40 |
Correct |
135 ms |
452428 KB |
Output is correct |
41 |
Correct |
143 ms |
452276 KB |
Output is correct |
42 |
Correct |
166 ms |
452428 KB |
Output is correct |
43 |
Correct |
141 ms |
452180 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
150 ms |
451976 KB |
Output is correct |
2 |
Correct |
152 ms |
452172 KB |
Output is correct |
3 |
Correct |
158 ms |
452176 KB |
Output is correct |
4 |
Correct |
157 ms |
452340 KB |
Output is correct |
5 |
Correct |
142 ms |
452176 KB |
Output is correct |
6 |
Correct |
148 ms |
452284 KB |
Output is correct |
7 |
Correct |
154 ms |
452368 KB |
Output is correct |
8 |
Correct |
155 ms |
452060 KB |
Output is correct |
9 |
Correct |
155 ms |
452180 KB |
Output is correct |
10 |
Correct |
150 ms |
452172 KB |
Output is correct |
11 |
Correct |
154 ms |
452176 KB |
Output is correct |
12 |
Correct |
169 ms |
451960 KB |
Output is correct |
13 |
Correct |
147 ms |
452284 KB |
Output is correct |
14 |
Correct |
182 ms |
452196 KB |
Output is correct |
15 |
Correct |
155 ms |
452176 KB |
Output is correct |
16 |
Correct |
148 ms |
452176 KB |
Output is correct |
17 |
Correct |
169 ms |
452224 KB |
Output is correct |
18 |
Correct |
167 ms |
452260 KB |
Output is correct |
19 |
Correct |
152 ms |
452172 KB |
Output is correct |
20 |
Correct |
144 ms |
452176 KB |
Output is correct |
21 |
Correct |
136 ms |
452252 KB |
Output is correct |
22 |
Correct |
164 ms |
452408 KB |
Output is correct |
23 |
Correct |
143 ms |
452176 KB |
Output is correct |
24 |
Correct |
150 ms |
452176 KB |
Output is correct |
25 |
Correct |
144 ms |
452176 KB |
Output is correct |
26 |
Correct |
138 ms |
452176 KB |
Output is correct |
27 |
Correct |
147 ms |
452176 KB |
Output is correct |
28 |
Correct |
152 ms |
452232 KB |
Output is correct |
29 |
Correct |
142 ms |
452176 KB |
Output is correct |
30 |
Correct |
161 ms |
452376 KB |
Output is correct |
31 |
Correct |
141 ms |
452176 KB |
Output is correct |
32 |
Correct |
159 ms |
452176 KB |
Output is correct |
33 |
Correct |
146 ms |
452140 KB |
Output is correct |
34 |
Correct |
144 ms |
452180 KB |
Output is correct |
35 |
Correct |
145 ms |
452172 KB |
Output is correct |
36 |
Correct |
257 ms |
463908 KB |
Output is correct |
37 |
Correct |
333 ms |
470516 KB |
Output is correct |
38 |
Correct |
365 ms |
470464 KB |
Output is correct |
39 |
Correct |
365 ms |
472008 KB |
Output is correct |
40 |
Correct |
420 ms |
471888 KB |
Output is correct |
41 |
Correct |
369 ms |
471868 KB |
Output is correct |
42 |
Correct |
395 ms |
471972 KB |
Output is correct |
43 |
Correct |
266 ms |
467540 KB |
Output is correct |
44 |
Correct |
295 ms |
467536 KB |
Output is correct |
45 |
Correct |
267 ms |
467536 KB |
Output is correct |
46 |
Correct |
269 ms |
467588 KB |
Output is correct |
47 |
Correct |
343 ms |
470452 KB |
Output is correct |
48 |
Correct |
433 ms |
472064 KB |
Output is correct |
49 |
Correct |
396 ms |
471872 KB |
Output is correct |
50 |
Correct |
274 ms |
467536 KB |
Output is correct |
51 |
Correct |
290 ms |
467540 KB |
Output is correct |
52 |
Correct |
358 ms |
470464 KB |
Output is correct |
53 |
Correct |
363 ms |
471872 KB |
Output is correct |
54 |
Correct |
395 ms |
472016 KB |
Output is correct |
55 |
Correct |
271 ms |
467536 KB |
Output is correct |
56 |
Correct |
282 ms |
467536 KB |
Output is correct |
57 |
Correct |
326 ms |
469804 KB |
Output is correct |
58 |
Correct |
356 ms |
470480 KB |
Output is correct |
59 |
Correct |
347 ms |
470464 KB |
Output is correct |
60 |
Correct |
393 ms |
471848 KB |
Output is correct |
61 |
Correct |
395 ms |
471892 KB |
Output is correct |
62 |
Correct |
395 ms |
472024 KB |
Output is correct |
63 |
Correct |
385 ms |
472128 KB |
Output is correct |
64 |
Correct |
264 ms |
467532 KB |
Output is correct |
65 |
Correct |
260 ms |
467536 KB |
Output is correct |
66 |
Correct |
258 ms |
467536 KB |
Output is correct |
67 |
Correct |
272 ms |
467456 KB |
Output is correct |
68 |
Correct |
1213 ms |
470468 KB |
Output is correct |
69 |
Correct |
1542 ms |
470568 KB |
Output is correct |
70 |
Correct |
1482 ms |
470464 KB |
Output is correct |
71 |
Correct |
1621 ms |
471892 KB |
Output is correct |
72 |
Correct |
1473 ms |
472084 KB |
Output is correct |
73 |
Correct |
1406 ms |
471924 KB |
Output is correct |
74 |
Correct |
1536 ms |
472172 KB |
Output is correct |
75 |
Correct |
1532 ms |
467676 KB |
Output is correct |
76 |
Correct |
1432 ms |
467532 KB |
Output is correct |
77 |
Correct |
1366 ms |
467536 KB |
Output is correct |
78 |
Correct |
1389 ms |
467508 KB |
Output is correct |
79 |
Correct |
1372 ms |
467536 KB |
Output is correct |
80 |
Correct |
1368 ms |
467536 KB |
Output is correct |
81 |
Correct |
157 ms |
451920 KB |
Output is correct |
82 |
Correct |
153 ms |
452176 KB |
Output is correct |
83 |
Correct |
153 ms |
452172 KB |
Output is correct |
84 |
Correct |
346 ms |
470540 KB |
Output is correct |
85 |
Correct |
385 ms |
471888 KB |
Output is correct |
86 |
Correct |
361 ms |
471864 KB |
Output is correct |
87 |
Correct |
260 ms |
467620 KB |
Output is correct |
88 |
Correct |
255 ms |
467536 KB |
Output is correct |
89 |
Correct |
348 ms |
470460 KB |
Output is correct |
90 |
Correct |
424 ms |
471928 KB |
Output is correct |
91 |
Correct |
388 ms |
471868 KB |
Output is correct |
92 |
Correct |
275 ms |
467560 KB |
Output is correct |
93 |
Correct |
262 ms |
467536 KB |
Output is correct |
94 |
Correct |
154 ms |
452268 KB |
Output is correct |
95 |
Correct |
154 ms |
452236 KB |
Output is correct |
96 |
Correct |
155 ms |
452176 KB |
Output is correct |
97 |
Correct |
148 ms |
452176 KB |
Output is correct |
98 |
Correct |
154 ms |
452140 KB |
Output is correct |
99 |
Correct |
145 ms |
452380 KB |
Output is correct |
100 |
Correct |
147 ms |
452168 KB |
Output is correct |
101 |
Correct |
150 ms |
452396 KB |
Output is correct |
102 |
Correct |
146 ms |
452176 KB |
Output is correct |
103 |
Correct |
146 ms |
452128 KB |
Output is correct |
104 |
Correct |
1344 ms |
468428 KB |
Output is correct |
105 |
Correct |
1434 ms |
470592 KB |
Output is correct |
106 |
Correct |
1510 ms |
470452 KB |
Output is correct |
107 |
Correct |
1467 ms |
471868 KB |
Output is correct |
108 |
Correct |
1590 ms |
471956 KB |
Output is correct |
109 |
Correct |
1478 ms |
471916 KB |
Output is correct |
110 |
Correct |
1394 ms |
471864 KB |
Output is correct |
111 |
Correct |
1343 ms |
467452 KB |
Output is correct |
112 |
Correct |
1362 ms |
467652 KB |
Output is correct |
113 |
Correct |
1344 ms |
467536 KB |
Output is correct |
114 |
Correct |
1356 ms |
467536 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1018 ms |
461136 KB |
Output is correct |
2 |
Correct |
1841 ms |
467492 KB |
Output is correct |
3 |
Correct |
1652 ms |
467568 KB |
Output is correct |
4 |
Correct |
1474 ms |
467536 KB |
Output is correct |
5 |
Correct |
1438 ms |
467480 KB |
Output is correct |
6 |
Correct |
1494 ms |
467536 KB |
Output is correct |
7 |
Correct |
1376 ms |
467536 KB |
Output is correct |
8 |
Correct |
146 ms |
451992 KB |
Output is correct |
9 |
Correct |
156 ms |
452292 KB |
Output is correct |
10 |
Correct |
159 ms |
452260 KB |
Output is correct |
11 |
Correct |
150 ms |
451976 KB |
Output is correct |
12 |
Correct |
152 ms |
452172 KB |
Output is correct |
13 |
Correct |
158 ms |
452176 KB |
Output is correct |
14 |
Correct |
157 ms |
452340 KB |
Output is correct |
15 |
Correct |
142 ms |
452176 KB |
Output is correct |
16 |
Correct |
148 ms |
452284 KB |
Output is correct |
17 |
Correct |
154 ms |
452368 KB |
Output is correct |
18 |
Correct |
155 ms |
452060 KB |
Output is correct |
19 |
Correct |
155 ms |
452180 KB |
Output is correct |
20 |
Correct |
150 ms |
452172 KB |
Output is correct |
21 |
Correct |
154 ms |
452176 KB |
Output is correct |
22 |
Correct |
169 ms |
451960 KB |
Output is correct |
23 |
Correct |
147 ms |
452284 KB |
Output is correct |
24 |
Correct |
182 ms |
452196 KB |
Output is correct |
25 |
Correct |
155 ms |
452176 KB |
Output is correct |
26 |
Correct |
148 ms |
452176 KB |
Output is correct |
27 |
Correct |
169 ms |
452224 KB |
Output is correct |
28 |
Correct |
167 ms |
452260 KB |
Output is correct |
29 |
Correct |
152 ms |
452172 KB |
Output is correct |
30 |
Correct |
144 ms |
452176 KB |
Output is correct |
31 |
Correct |
136 ms |
452252 KB |
Output is correct |
32 |
Correct |
164 ms |
452408 KB |
Output is correct |
33 |
Correct |
143 ms |
452176 KB |
Output is correct |
34 |
Correct |
150 ms |
452176 KB |
Output is correct |
35 |
Correct |
144 ms |
452176 KB |
Output is correct |
36 |
Correct |
138 ms |
452176 KB |
Output is correct |
37 |
Correct |
147 ms |
452176 KB |
Output is correct |
38 |
Correct |
152 ms |
452232 KB |
Output is correct |
39 |
Correct |
142 ms |
452176 KB |
Output is correct |
40 |
Correct |
161 ms |
452376 KB |
Output is correct |
41 |
Correct |
141 ms |
452176 KB |
Output is correct |
42 |
Correct |
159 ms |
452176 KB |
Output is correct |
43 |
Correct |
146 ms |
452140 KB |
Output is correct |
44 |
Correct |
144 ms |
452180 KB |
Output is correct |
45 |
Correct |
145 ms |
452172 KB |
Output is correct |
46 |
Correct |
257 ms |
463908 KB |
Output is correct |
47 |
Correct |
333 ms |
470516 KB |
Output is correct |
48 |
Correct |
365 ms |
470464 KB |
Output is correct |
49 |
Correct |
365 ms |
472008 KB |
Output is correct |
50 |
Correct |
420 ms |
471888 KB |
Output is correct |
51 |
Correct |
369 ms |
471868 KB |
Output is correct |
52 |
Correct |
395 ms |
471972 KB |
Output is correct |
53 |
Correct |
266 ms |
467540 KB |
Output is correct |
54 |
Correct |
295 ms |
467536 KB |
Output is correct |
55 |
Correct |
267 ms |
467536 KB |
Output is correct |
56 |
Correct |
269 ms |
467588 KB |
Output is correct |
57 |
Correct |
343 ms |
470452 KB |
Output is correct |
58 |
Correct |
433 ms |
472064 KB |
Output is correct |
59 |
Correct |
396 ms |
471872 KB |
Output is correct |
60 |
Correct |
274 ms |
467536 KB |
Output is correct |
61 |
Correct |
290 ms |
467540 KB |
Output is correct |
62 |
Correct |
358 ms |
470464 KB |
Output is correct |
63 |
Correct |
363 ms |
471872 KB |
Output is correct |
64 |
Correct |
395 ms |
472016 KB |
Output is correct |
65 |
Correct |
271 ms |
467536 KB |
Output is correct |
66 |
Correct |
282 ms |
467536 KB |
Output is correct |
67 |
Correct |
326 ms |
469804 KB |
Output is correct |
68 |
Correct |
356 ms |
470480 KB |
Output is correct |
69 |
Correct |
347 ms |
470464 KB |
Output is correct |
70 |
Correct |
393 ms |
471848 KB |
Output is correct |
71 |
Correct |
395 ms |
471892 KB |
Output is correct |
72 |
Correct |
395 ms |
472024 KB |
Output is correct |
73 |
Correct |
385 ms |
472128 KB |
Output is correct |
74 |
Correct |
264 ms |
467532 KB |
Output is correct |
75 |
Correct |
260 ms |
467536 KB |
Output is correct |
76 |
Correct |
258 ms |
467536 KB |
Output is correct |
77 |
Correct |
272 ms |
467456 KB |
Output is correct |
78 |
Correct |
1213 ms |
470468 KB |
Output is correct |
79 |
Correct |
1542 ms |
470568 KB |
Output is correct |
80 |
Correct |
1482 ms |
470464 KB |
Output is correct |
81 |
Correct |
1621 ms |
471892 KB |
Output is correct |
82 |
Correct |
1473 ms |
472084 KB |
Output is correct |
83 |
Correct |
1406 ms |
471924 KB |
Output is correct |
84 |
Correct |
1536 ms |
472172 KB |
Output is correct |
85 |
Correct |
1532 ms |
467676 KB |
Output is correct |
86 |
Correct |
1432 ms |
467532 KB |
Output is correct |
87 |
Correct |
1366 ms |
467536 KB |
Output is correct |
88 |
Correct |
1389 ms |
467508 KB |
Output is correct |
89 |
Correct |
1372 ms |
467536 KB |
Output is correct |
90 |
Correct |
1368 ms |
467536 KB |
Output is correct |
91 |
Correct |
157 ms |
451920 KB |
Output is correct |
92 |
Correct |
153 ms |
452176 KB |
Output is correct |
93 |
Correct |
153 ms |
452172 KB |
Output is correct |
94 |
Correct |
346 ms |
470540 KB |
Output is correct |
95 |
Correct |
385 ms |
471888 KB |
Output is correct |
96 |
Correct |
361 ms |
471864 KB |
Output is correct |
97 |
Correct |
260 ms |
467620 KB |
Output is correct |
98 |
Correct |
255 ms |
467536 KB |
Output is correct |
99 |
Correct |
348 ms |
470460 KB |
Output is correct |
100 |
Correct |
424 ms |
471928 KB |
Output is correct |
101 |
Correct |
388 ms |
471868 KB |
Output is correct |
102 |
Correct |
275 ms |
467560 KB |
Output is correct |
103 |
Correct |
262 ms |
467536 KB |
Output is correct |
104 |
Correct |
154 ms |
452268 KB |
Output is correct |
105 |
Correct |
154 ms |
452236 KB |
Output is correct |
106 |
Correct |
155 ms |
452176 KB |
Output is correct |
107 |
Correct |
148 ms |
452176 KB |
Output is correct |
108 |
Correct |
154 ms |
452140 KB |
Output is correct |
109 |
Correct |
145 ms |
452380 KB |
Output is correct |
110 |
Correct |
147 ms |
452168 KB |
Output is correct |
111 |
Correct |
150 ms |
452396 KB |
Output is correct |
112 |
Correct |
146 ms |
452176 KB |
Output is correct |
113 |
Correct |
146 ms |
452128 KB |
Output is correct |
114 |
Correct |
446 ms |
456320 KB |
Output is correct |
115 |
Correct |
1100 ms |
470536 KB |
Output is correct |
116 |
Correct |
1204 ms |
470436 KB |
Output is correct |
117 |
Correct |
1148 ms |
472068 KB |
Output is correct |
118 |
Correct |
1204 ms |
471928 KB |
Output is correct |
119 |
Correct |
1136 ms |
471884 KB |
Output is correct |
120 |
Correct |
1113 ms |
471868 KB |
Output is correct |
121 |
Correct |
975 ms |
467536 KB |
Output is correct |
122 |
Correct |
982 ms |
467536 KB |
Output is correct |
123 |
Correct |
952 ms |
467536 KB |
Output is correct |
124 |
Correct |
982 ms |
467560 KB |
Output is correct |
125 |
Correct |
318 ms |
470464 KB |
Output is correct |
126 |
Correct |
351 ms |
471904 KB |
Output is correct |
127 |
Correct |
358 ms |
472012 KB |
Output is correct |
128 |
Correct |
283 ms |
467536 KB |
Output is correct |
129 |
Correct |
241 ms |
467536 KB |
Output is correct |
130 |
Correct |
314 ms |
469932 KB |
Output is correct |
131 |
Correct |
340 ms |
470468 KB |
Output is correct |
132 |
Correct |
372 ms |
470464 KB |
Output is correct |
133 |
Correct |
362 ms |
471916 KB |
Output is correct |
134 |
Correct |
413 ms |
471952 KB |
Output is correct |
135 |
Correct |
429 ms |
471868 KB |
Output is correct |
136 |
Correct |
405 ms |
471968 KB |
Output is correct |
137 |
Correct |
284 ms |
466768 KB |
Output is correct |
138 |
Correct |
266 ms |
466940 KB |
Output is correct |
139 |
Correct |
287 ms |
467024 KB |
Output is correct |
140 |
Correct |
313 ms |
467024 KB |
Output is correct |
141 |
Correct |
159 ms |
451664 KB |
Output is correct |
142 |
Correct |
144 ms |
451712 KB |
Output is correct |
143 |
Correct |
155 ms |
452176 KB |
Output is correct |
144 |
Correct |
142 ms |
452176 KB |
Output is correct |
145 |
Correct |
139 ms |
452144 KB |
Output is correct |
146 |
Correct |
173 ms |
452180 KB |
Output is correct |
147 |
Correct |
143 ms |
452212 KB |
Output is correct |
148 |
Correct |
195 ms |
452180 KB |
Output is correct |
149 |
Correct |
145 ms |
452200 KB |
Output is correct |
150 |
Correct |
148 ms |
452176 KB |
Output is correct |
151 |
Correct |
142 ms |
452240 KB |
Output is correct |
152 |
Correct |
152 ms |
452324 KB |
Output is correct |
153 |
Correct |
135 ms |
452428 KB |
Output is correct |
154 |
Correct |
143 ms |
452276 KB |
Output is correct |
155 |
Correct |
166 ms |
452428 KB |
Output is correct |
156 |
Correct |
141 ms |
452180 KB |
Output is correct |
157 |
Correct |
1344 ms |
468428 KB |
Output is correct |
158 |
Correct |
1434 ms |
470592 KB |
Output is correct |
159 |
Correct |
1510 ms |
470452 KB |
Output is correct |
160 |
Correct |
1467 ms |
471868 KB |
Output is correct |
161 |
Correct |
1590 ms |
471956 KB |
Output is correct |
162 |
Correct |
1478 ms |
471916 KB |
Output is correct |
163 |
Correct |
1394 ms |
471864 KB |
Output is correct |
164 |
Correct |
1343 ms |
467452 KB |
Output is correct |
165 |
Correct |
1362 ms |
467652 KB |
Output is correct |
166 |
Correct |
1344 ms |
467536 KB |
Output is correct |
167 |
Correct |
1356 ms |
467536 KB |
Output is correct |
168 |
Correct |
146 ms |
451924 KB |
Output is correct |
169 |
Correct |
1041 ms |
458228 KB |
Output is correct |
170 |
Correct |
1940 ms |
470468 KB |
Output is correct |
171 |
Correct |
1986 ms |
470560 KB |
Output is correct |
172 |
Correct |
1810 ms |
471840 KB |
Output is correct |
173 |
Correct |
1768 ms |
471872 KB |
Output is correct |
174 |
Correct |
1673 ms |
471952 KB |
Output is correct |
175 |
Correct |
1740 ms |
472128 KB |
Output is correct |
176 |
Correct |
1397 ms |
467536 KB |
Output is correct |
177 |
Correct |
1360 ms |
467760 KB |
Output is correct |
178 |
Correct |
1390 ms |
467536 KB |
Output is correct |
179 |
Correct |
1399 ms |
467636 KB |
Output is correct |