Submission #771496

# Submission time Handle Problem Language Result Execution time Memory
771496 2023-07-03T05:17:06 Z PurpleCrayon Radio Towers (IOI22_towers) C++17
100 / 100
1739 ms 172524 KB
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;

#define sz(v) int(v.size())
#define ar array
typedef long long ll;
const int N = 1e5+10, MOD = 1e9+7;
const ll INF = 1e18+10;
const int L = 20;

struct D1 {
    int sum, mn, mx;

    D1() {
        sum = 0;
        mn = MOD;
        mx = -1;
    }

    D1(int x, int loc) {
        sum = x;
        if (x) mn = mx = loc;
        else mn = MOD, mx = -1;
    }

    friend D1 operator + (const D1& one, const D1& two) {
        D1 ans;
        ans.sum = one.sum + two.sum;
        ans.mn = min(one.mn, two.mn);
        ans.mx = max(one.mx, two.mx);
        return ans;
    }
};

struct T1 {
    D1 d;
    T1 *l, *r;

    T1(D1 _d): d(_d) {
        l = nullptr;
        r = nullptr;
    }

    T1(T1* _l, T1* _r): l(_l), r(_r) {
        d = l->d + r->d;
    }
};

T1* build1(int tl, int tr, const vector<int>& v) {
    if (tl == tr) {
        return new T1(D1(v[tl], tl));
    }
    else {
        int tm = (tl + tr) / 2;
        T1* ans = new T1(build1(tl, tm, v), build1(tm+1, tr, v));
        return ans;
    }
}

T1* upd1(T1* t, int tl, int tr, int pos, int x) {
    if (tl == tr) {
        return new T1(D1(x, tl));
    }
    int tm = (tl + tr) / 2;
    if (pos <= tm)
        return new T1(upd1(t->l, tl, tm, pos, x), t->r);
    else
        return new T1(t->l, upd1(t->r, tm+1, tr, pos, x));
}

D1 qry1(T1* t, int tl, int tr, int l, int r) {
    if (r < tl || l > tr) return D1();
    if (l <= tl && tr <= r) return t->d;
    int tm = (tl + tr) / 2;
    return qry1(t->l, tl, tm, l, r) + qry1(t->r, tm+1, tr, l, r);
}

struct D2 {
    int mn, left_big, right_big, mx_active;

    D2() {
        mn = MOD;
        left_big = right_big = -1;
        mx_active = -MOD;
    }

    D2(int x, bool active) {
        mn = x;
        left_big = right_big = -1;
        if (active) mx_active = x;
        else mx_active = -MOD;
    }

    friend D2 operator + (const D2& one, const D2& two) {
        D2 res;
        res.mn = min(one.mn, two.mn);
        res.mx_active = max(one.mx_active, two.mx_active);
        res.right_big = max({one.right_big, two.right_big, two.mx_active - one.mn});
        res.left_big = max({one.left_big, two.left_big, one.mx_active - two.mn});
        return res;
    }
};

struct T2 {
    D2 d;
    T2 *l, *r;

    T2(D2 _d): d(_d) {
        l = nullptr;
        r = nullptr;
    }

    T2(T2* _l, T2* _r): l(_l), r(_r) {
        d = l->d + r->d;
    }
};

T2* build2(int tl, int tr, const vector<int>& v) {
    if (tl == tr) {
        return new T2(D2(v[tl], false));
    }
    else {
        int tm = (tl + tr) / 2;
        T2* ans = new T2(build2(tl, tm, v), build2(tm+1, tr, v));
        return ans;
    }
}

T2* upd2(T2* t, int tl, int tr, int pos, int x) {
    if (tl == tr) {
        return new T2(D2(x, true));
    }
    int tm = (tl + tr) / 2;
    if (pos <= tm)
        return new T2(upd2(t->l, tl, tm, pos, x), t->r);
    else
        return new T2(t->l, upd2(t->r, tm+1, tr, pos, x));
}

D2 qry2(T2* t, int tl, int tr, int l, int r) {
    if (r < tl || l > tr) return D2();
    if (l <= tl && tr <= r) return t->d;
    int tm = (tl + tr) / 2;
    return qry2(t->l, tl, tm, l, r) + qry2(t->r, tm+1, tr, l, r);
}


int n, a[N], st[N][L];
vector<pair<int, int>> store;
vector<int> base;
vector<int> ord;
T1* vers[N];
ar<int, 2> st_min[N][L];

pair<int, int> sorted[N];
T2* vers2[N];

void build_rmq() {
    for (int i = 0; i < n; i++) st[i][0] = a[i];
    for (int k = 2, l = 1; k <= n; k *= 2, l++) {
        for (int i = 0; i + k <= n; i++) {
            st[i][l] = max(st[i][l-1], st[i + k / 2][l-1]);
        }
    }

    for (int i = 0; i < n; i++) st_min[i][0] = {a[i], i};
    for (int k = 2, l = 1; k <= n; k *= 2, l++) {
        for (int i = 0; i + k <= n; i++) {
            st_min[i][l] = min(st_min[i][l-1], st_min[i + k / 2][l-1]);
        }
    }
}

int qry_max(int l, int r) {
    int len = r - l + 1;
    int use = 31 - __builtin_clz(len);
    return max(st[l][use], st[r - (1 << use) + 1][use]);
}

ar<int, 2> qry_min(int l, int r) {
    int len = r - l + 1;
    int use = 31 - __builtin_clz(len);
    return min(st_min[l][use], st_min[r - (1 << use) + 1][use]);
}

void init(int _n, vector<int> H) {
    n = _n;
    for (int i = 0; i < n; i++) {
        a[i] = H[i];
    }
    build_rmq();

    set<int> s;
    for (int i = 0; i < n; i++) {
        bool use = 1;
        if (i && a[i-1] < a[i]) use = 0;
        if (i < n-1 && a[i+1] < a[i]) use = 0;
        if (use) s.insert(i);
    }
    base = vector<int>(s.begin(), s.end());

    auto f = [&](int i) {
        auto it = s.lower_bound(i); assert(*it == i);
        --it;
        return qry_max(*it, i) - max(a[*it], a[i]);
    };

    set<pair<int, int>> q;
    auto get_v = [&](int x) {
        return pair<int, int>{f(x), x};
    };

    for (auto it = next(s.begin()); it != s.end(); it++) {
        q.insert(get_v(*it));
    }

    vector<pair<int, int>> v;
    v.emplace_back(0, sz(s)); // d > 0, ans = sz(s)
    while (sz(q)) {
        auto [d, i] = *q.begin(); q.erase(q.begin());
        v.emplace_back(d, -1); // need to update v.back().second

        auto it = s.lower_bound(i); assert(*it == i);
        int one = i;
        int two = *prev(it);
        if (next(it) != s.end()) {
            q.erase(get_v(*next(it)));
        }

        if (prev(it) != s.begin()) {
            q.erase(get_v(two));
        }

        if (a[one] > a[two]) {
            s.erase(one);
            ord.push_back(one);
            it = s.lower_bound(two);
            if (next(it) != s.end()) {
                q.insert(get_v(*next(it)));
            }
            if (it != s.begin()) {
                q.insert(get_v(*it));
            }
        } else {
            s.erase(two);
            ord.push_back(two);
            it = s.lower_bound(one);
            if (next(it) != s.end()) {
                q.insert(get_v(*next(it)));
            }
            if (it != s.begin()) {
                q.insert(get_v(*it));
            }
        }

        v.back().second = sz(s);
    }

    store.push_back(v[0]);
    for (int i = 1; i < sz(v); i++) {
        if (v[i].first <= store.back().first) {
            store.back().second = v[i].second;
        } else {
            store.push_back(v[i]);
        }
    }

    vector<int> aux_base(n);
    for (int x : base) aux_base[x] = 1;
    vers[0] = build1(0, n-1, aux_base);
    // cerr << "done\n";
    for (int i = 1; i <= sz(ord); i++) {
        vers[i] = upd1(vers[i-1], 0, n-1, ord[i-1], 0);
    }
    // cerr << "done\n";
    for (int i = 0; i < n; i++) {
        sorted[i] = {a[i], i};
    }
    sort(sorted, sorted + n);
    vector<int> av(a, a + n);
    vers2[n] = build2(0, n-1, av);
    for (int i = n-1; i >= 0; i--) {
        vers2[i] = upd2(vers2[i+1], 0, n-1, sorted[i].second, sorted[i].first);
    }
}

int max_towers(int l, int r, int d) {
    if (r - l + 1 <= 2) return 1;
    // find the last thing < d
    int idx = lower_bound(store.begin(), store.end(), pair<int, int>{d, -1}) - store.begin() - 1;
    int gone = sz(base) - store[idx].second;

    D1 dd = qry1(vers[gone], 0, n-1, l, r);
    int ans = dd.sum;
    int first = dd.mn, last = dd.mx;

    if (ans == 0) {
        auto [mn_v, mn_idx] = qry_min(l, r);
        bool one = 0, two = 0;
        int idx1 = lower_bound(sorted, sorted + n, pair<int, int>{mn_v + d, -1}) - sorted;
        one = qry2(vers2[idx1], 0, n-1, l, mn_idx).right_big >= d;
        two = qry2(vers2[idx1], 0, n-1, mn_idx, r).left_big >= d;
        return int(one) + 1 + two;
    }

    bool one = 0, two = 0;
    int idx1 = lower_bound(sorted, sorted + n, pair<int, int>{a[first] + d, -1}) - sorted;
    int idx2 = lower_bound(sorted, sorted + n, pair<int, int>{a[last] + d, -1}) - sorted;
    one = qry2(vers2[idx1], 0, n-1, l, first).right_big >= d;
    two = qry2(vers2[idx2], 0, n-1, last, r).left_big >= d;

    /*
    bool one = 0, two = 0;
    for (int i = l; i < first; i++) {
        int x = qry_max(i, first);
        if (a[i] <= x - d && x - d >= a[first]) {
            one = 1;
            break;
        }
    }

    for (int i = last+1; i <= r; i++) {
        int x = qry_max(last, i);
        if (a[i] <= x - d && x - d >= a[last]) {
            two = 1;
            break;
        }
    }
    */

    ans += one;
    ans += two;

    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 462 ms 74972 KB Output is correct
2 Correct 1010 ms 129096 KB Output is correct
3 Correct 1060 ms 129068 KB Output is correct
4 Correct 1213 ms 129144 KB Output is correct
5 Correct 1131 ms 129048 KB Output is correct
6 Correct 1134 ms 129092 KB Output is correct
7 Correct 1073 ms 129064 KB Output is correct
8 Correct 0 ms 336 KB Output is correct
9 Correct 2 ms 2256 KB Output is correct
10 Correct 2 ms 2256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 720 KB Output is correct
2 Correct 4 ms 2768 KB Output is correct
3 Correct 3 ms 2640 KB Output is correct
4 Correct 4 ms 2896 KB Output is correct
5 Correct 4 ms 2896 KB Output is correct
6 Correct 3 ms 2896 KB Output is correct
7 Correct 4 ms 2896 KB Output is correct
8 Correct 2 ms 2256 KB Output is correct
9 Correct 2 ms 2256 KB Output is correct
10 Correct 2 ms 2256 KB Output is correct
11 Correct 2 ms 2256 KB Output is correct
12 Correct 0 ms 336 KB Output is correct
13 Correct 2 ms 2256 KB Output is correct
14 Correct 2 ms 2256 KB Output is correct
15 Correct 4 ms 2768 KB Output is correct
16 Correct 4 ms 2844 KB Output is correct
17 Correct 4 ms 2896 KB Output is correct
18 Correct 2 ms 2256 KB Output is correct
19 Correct 2 ms 2256 KB Output is correct
20 Correct 4 ms 2768 KB Output is correct
21 Correct 4 ms 2896 KB Output is correct
22 Correct 4 ms 2896 KB Output is correct
23 Correct 2 ms 2256 KB Output is correct
24 Correct 2 ms 2256 KB Output is correct
25 Correct 1 ms 1360 KB Output is correct
26 Correct 3 ms 2768 KB Output is correct
27 Correct 3 ms 2640 KB Output is correct
28 Correct 4 ms 2896 KB Output is correct
29 Correct 4 ms 2896 KB Output is correct
30 Correct 4 ms 2896 KB Output is correct
31 Correct 4 ms 2896 KB Output is correct
32 Correct 2 ms 2256 KB Output is correct
33 Correct 2 ms 2304 KB Output is correct
34 Correct 2 ms 2256 KB Output is correct
35 Correct 2 ms 2256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 720 KB Output is correct
2 Correct 4 ms 2768 KB Output is correct
3 Correct 3 ms 2640 KB Output is correct
4 Correct 4 ms 2896 KB Output is correct
5 Correct 4 ms 2896 KB Output is correct
6 Correct 3 ms 2896 KB Output is correct
7 Correct 4 ms 2896 KB Output is correct
8 Correct 2 ms 2256 KB Output is correct
9 Correct 2 ms 2256 KB Output is correct
10 Correct 2 ms 2256 KB Output is correct
11 Correct 2 ms 2256 KB Output is correct
12 Correct 0 ms 336 KB Output is correct
13 Correct 2 ms 2256 KB Output is correct
14 Correct 2 ms 2256 KB Output is correct
15 Correct 4 ms 2768 KB Output is correct
16 Correct 4 ms 2844 KB Output is correct
17 Correct 4 ms 2896 KB Output is correct
18 Correct 2 ms 2256 KB Output is correct
19 Correct 2 ms 2256 KB Output is correct
20 Correct 4 ms 2768 KB Output is correct
21 Correct 4 ms 2896 KB Output is correct
22 Correct 4 ms 2896 KB Output is correct
23 Correct 2 ms 2256 KB Output is correct
24 Correct 2 ms 2256 KB Output is correct
25 Correct 1 ms 1360 KB Output is correct
26 Correct 3 ms 2768 KB Output is correct
27 Correct 3 ms 2640 KB Output is correct
28 Correct 4 ms 2896 KB Output is correct
29 Correct 4 ms 2896 KB Output is correct
30 Correct 4 ms 2896 KB Output is correct
31 Correct 4 ms 2896 KB Output is correct
32 Correct 2 ms 2256 KB Output is correct
33 Correct 2 ms 2304 KB Output is correct
34 Correct 2 ms 2256 KB Output is correct
35 Correct 2 ms 2256 KB Output is correct
36 Correct 155 ms 99948 KB Output is correct
37 Correct 262 ms 158228 KB Output is correct
38 Correct 254 ms 158016 KB Output is correct
39 Correct 333 ms 172288 KB Output is correct
40 Correct 324 ms 172356 KB Output is correct
41 Correct 328 ms 172332 KB Output is correct
42 Correct 326 ms 172340 KB Output is correct
43 Correct 107 ms 129060 KB Output is correct
44 Correct 115 ms 129216 KB Output is correct
45 Correct 106 ms 129100 KB Output is correct
46 Correct 126 ms 129100 KB Output is correct
47 Correct 262 ms 158044 KB Output is correct
48 Correct 315 ms 172364 KB Output is correct
49 Correct 320 ms 172396 KB Output is correct
50 Correct 108 ms 129148 KB Output is correct
51 Correct 110 ms 129152 KB Output is correct
52 Correct 266 ms 158012 KB Output is correct
53 Correct 328 ms 172496 KB Output is correct
54 Correct 322 ms 172316 KB Output is correct
55 Correct 113 ms 129068 KB Output is correct
56 Correct 107 ms 129096 KB Output is correct
57 Correct 246 ms 152268 KB Output is correct
58 Correct 263 ms 158136 KB Output is correct
59 Correct 268 ms 158228 KB Output is correct
60 Correct 325 ms 172404 KB Output is correct
61 Correct 330 ms 172372 KB Output is correct
62 Correct 322 ms 172348 KB Output is correct
63 Correct 320 ms 172392 KB Output is correct
64 Correct 112 ms 129176 KB Output is correct
65 Correct 114 ms 129068 KB Output is correct
66 Correct 111 ms 129140 KB Output is correct
67 Correct 121 ms 129116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1140 ms 156928 KB Output is correct
2 Correct 1563 ms 158080 KB Output is correct
3 Correct 1519 ms 158080 KB Output is correct
4 Correct 1602 ms 172356 KB Output is correct
5 Correct 1550 ms 172304 KB Output is correct
6 Correct 1513 ms 172344 KB Output is correct
7 Correct 1493 ms 172328 KB Output is correct
8 Correct 1216 ms 129056 KB Output is correct
9 Correct 1055 ms 129124 KB Output is correct
10 Correct 1093 ms 129068 KB Output is correct
11 Correct 1119 ms 129124 KB Output is correct
12 Correct 1151 ms 129084 KB Output is correct
13 Correct 1170 ms 129096 KB Output is correct
14 Correct 0 ms 336 KB Output is correct
15 Correct 2 ms 2256 KB Output is correct
16 Correct 2 ms 2256 KB Output is correct
17 Correct 257 ms 158020 KB Output is correct
18 Correct 332 ms 172372 KB Output is correct
19 Correct 316 ms 172392 KB Output is correct
20 Correct 109 ms 129124 KB Output is correct
21 Correct 107 ms 129124 KB Output is correct
22 Correct 259 ms 158088 KB Output is correct
23 Correct 318 ms 172380 KB Output is correct
24 Correct 310 ms 172348 KB Output is correct
25 Correct 137 ms 129148 KB Output is correct
26 Correct 109 ms 129092 KB Output is correct
27 Correct 3 ms 2768 KB Output is correct
28 Correct 4 ms 2896 KB Output is correct
29 Correct 4 ms 2896 KB Output is correct
30 Correct 2 ms 2256 KB Output is correct
31 Correct 2 ms 2256 KB Output is correct
32 Correct 3 ms 2768 KB Output is correct
33 Correct 4 ms 2896 KB Output is correct
34 Correct 4 ms 2940 KB Output is correct
35 Correct 2 ms 2372 KB Output is correct
36 Correct 2 ms 2256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 293 ms 34872 KB Output is correct
2 Correct 1059 ms 158072 KB Output is correct
3 Correct 1045 ms 158104 KB Output is correct
4 Correct 1274 ms 172328 KB Output is correct
5 Correct 1190 ms 172524 KB Output is correct
6 Correct 1176 ms 172360 KB Output is correct
7 Correct 1218 ms 172376 KB Output is correct
8 Correct 900 ms 129144 KB Output is correct
9 Correct 972 ms 129148 KB Output is correct
10 Correct 990 ms 129108 KB Output is correct
11 Correct 891 ms 129172 KB Output is correct
12 Correct 260 ms 158100 KB Output is correct
13 Correct 370 ms 172372 KB Output is correct
14 Correct 324 ms 172360 KB Output is correct
15 Correct 135 ms 129052 KB Output is correct
16 Correct 111 ms 129096 KB Output is correct
17 Correct 286 ms 152200 KB Output is correct
18 Correct 258 ms 158092 KB Output is correct
19 Correct 259 ms 158188 KB Output is correct
20 Correct 324 ms 172412 KB Output is correct
21 Correct 328 ms 172332 KB Output is correct
22 Correct 334 ms 172328 KB Output is correct
23 Correct 321 ms 172364 KB Output is correct
24 Correct 114 ms 129160 KB Output is correct
25 Correct 109 ms 129120 KB Output is correct
26 Correct 108 ms 129152 KB Output is correct
27 Correct 108 ms 129076 KB Output is correct
28 Correct 3 ms 2768 KB Output is correct
29 Correct 4 ms 2896 KB Output is correct
30 Correct 4 ms 2896 KB Output is correct
31 Correct 2 ms 2256 KB Output is correct
32 Correct 2 ms 2256 KB Output is correct
33 Correct 1 ms 1360 KB Output is correct
34 Correct 3 ms 2768 KB Output is correct
35 Correct 3 ms 2640 KB Output is correct
36 Correct 4 ms 2896 KB Output is correct
37 Correct 4 ms 2896 KB Output is correct
38 Correct 4 ms 2896 KB Output is correct
39 Correct 4 ms 2896 KB Output is correct
40 Correct 2 ms 2256 KB Output is correct
41 Correct 2 ms 2256 KB Output is correct
42 Correct 2 ms 2256 KB Output is correct
43 Correct 2 ms 2256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 720 KB Output is correct
2 Correct 4 ms 2768 KB Output is correct
3 Correct 3 ms 2640 KB Output is correct
4 Correct 4 ms 2896 KB Output is correct
5 Correct 4 ms 2896 KB Output is correct
6 Correct 3 ms 2896 KB Output is correct
7 Correct 4 ms 2896 KB Output is correct
8 Correct 2 ms 2256 KB Output is correct
9 Correct 2 ms 2256 KB Output is correct
10 Correct 2 ms 2256 KB Output is correct
11 Correct 2 ms 2256 KB Output is correct
12 Correct 0 ms 336 KB Output is correct
13 Correct 2 ms 2256 KB Output is correct
14 Correct 2 ms 2256 KB Output is correct
15 Correct 4 ms 2768 KB Output is correct
16 Correct 4 ms 2844 KB Output is correct
17 Correct 4 ms 2896 KB Output is correct
18 Correct 2 ms 2256 KB Output is correct
19 Correct 2 ms 2256 KB Output is correct
20 Correct 4 ms 2768 KB Output is correct
21 Correct 4 ms 2896 KB Output is correct
22 Correct 4 ms 2896 KB Output is correct
23 Correct 2 ms 2256 KB Output is correct
24 Correct 2 ms 2256 KB Output is correct
25 Correct 1 ms 1360 KB Output is correct
26 Correct 3 ms 2768 KB Output is correct
27 Correct 3 ms 2640 KB Output is correct
28 Correct 4 ms 2896 KB Output is correct
29 Correct 4 ms 2896 KB Output is correct
30 Correct 4 ms 2896 KB Output is correct
31 Correct 4 ms 2896 KB Output is correct
32 Correct 2 ms 2256 KB Output is correct
33 Correct 2 ms 2304 KB Output is correct
34 Correct 2 ms 2256 KB Output is correct
35 Correct 2 ms 2256 KB Output is correct
36 Correct 155 ms 99948 KB Output is correct
37 Correct 262 ms 158228 KB Output is correct
38 Correct 254 ms 158016 KB Output is correct
39 Correct 333 ms 172288 KB Output is correct
40 Correct 324 ms 172356 KB Output is correct
41 Correct 328 ms 172332 KB Output is correct
42 Correct 326 ms 172340 KB Output is correct
43 Correct 107 ms 129060 KB Output is correct
44 Correct 115 ms 129216 KB Output is correct
45 Correct 106 ms 129100 KB Output is correct
46 Correct 126 ms 129100 KB Output is correct
47 Correct 262 ms 158044 KB Output is correct
48 Correct 315 ms 172364 KB Output is correct
49 Correct 320 ms 172396 KB Output is correct
50 Correct 108 ms 129148 KB Output is correct
51 Correct 110 ms 129152 KB Output is correct
52 Correct 266 ms 158012 KB Output is correct
53 Correct 328 ms 172496 KB Output is correct
54 Correct 322 ms 172316 KB Output is correct
55 Correct 113 ms 129068 KB Output is correct
56 Correct 107 ms 129096 KB Output is correct
57 Correct 246 ms 152268 KB Output is correct
58 Correct 263 ms 158136 KB Output is correct
59 Correct 268 ms 158228 KB Output is correct
60 Correct 325 ms 172404 KB Output is correct
61 Correct 330 ms 172372 KB Output is correct
62 Correct 322 ms 172348 KB Output is correct
63 Correct 320 ms 172392 KB Output is correct
64 Correct 112 ms 129176 KB Output is correct
65 Correct 114 ms 129068 KB Output is correct
66 Correct 111 ms 129140 KB Output is correct
67 Correct 121 ms 129116 KB Output is correct
68 Correct 1140 ms 156928 KB Output is correct
69 Correct 1563 ms 158080 KB Output is correct
70 Correct 1519 ms 158080 KB Output is correct
71 Correct 1602 ms 172356 KB Output is correct
72 Correct 1550 ms 172304 KB Output is correct
73 Correct 1513 ms 172344 KB Output is correct
74 Correct 1493 ms 172328 KB Output is correct
75 Correct 1216 ms 129056 KB Output is correct
76 Correct 1055 ms 129124 KB Output is correct
77 Correct 1093 ms 129068 KB Output is correct
78 Correct 1119 ms 129124 KB Output is correct
79 Correct 1151 ms 129084 KB Output is correct
80 Correct 1170 ms 129096 KB Output is correct
81 Correct 0 ms 336 KB Output is correct
82 Correct 2 ms 2256 KB Output is correct
83 Correct 2 ms 2256 KB Output is correct
84 Correct 257 ms 158020 KB Output is correct
85 Correct 332 ms 172372 KB Output is correct
86 Correct 316 ms 172392 KB Output is correct
87 Correct 109 ms 129124 KB Output is correct
88 Correct 107 ms 129124 KB Output is correct
89 Correct 259 ms 158088 KB Output is correct
90 Correct 318 ms 172380 KB Output is correct
91 Correct 310 ms 172348 KB Output is correct
92 Correct 137 ms 129148 KB Output is correct
93 Correct 109 ms 129092 KB Output is correct
94 Correct 3 ms 2768 KB Output is correct
95 Correct 4 ms 2896 KB Output is correct
96 Correct 4 ms 2896 KB Output is correct
97 Correct 2 ms 2256 KB Output is correct
98 Correct 2 ms 2256 KB Output is correct
99 Correct 3 ms 2768 KB Output is correct
100 Correct 4 ms 2896 KB Output is correct
101 Correct 4 ms 2940 KB Output is correct
102 Correct 2 ms 2372 KB Output is correct
103 Correct 2 ms 2256 KB Output is correct
104 Correct 1092 ms 139380 KB Output is correct
105 Correct 1421 ms 158020 KB Output is correct
106 Correct 1380 ms 158212 KB Output is correct
107 Correct 1562 ms 172400 KB Output is correct
108 Correct 1452 ms 172288 KB Output is correct
109 Correct 1454 ms 172328 KB Output is correct
110 Correct 1437 ms 172372 KB Output is correct
111 Correct 1029 ms 129072 KB Output is correct
112 Correct 1061 ms 129096 KB Output is correct
113 Correct 1067 ms 129096 KB Output is correct
114 Correct 1118 ms 129168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 462 ms 74972 KB Output is correct
2 Correct 1010 ms 129096 KB Output is correct
3 Correct 1060 ms 129068 KB Output is correct
4 Correct 1213 ms 129144 KB Output is correct
5 Correct 1131 ms 129048 KB Output is correct
6 Correct 1134 ms 129092 KB Output is correct
7 Correct 1073 ms 129064 KB Output is correct
8 Correct 0 ms 336 KB Output is correct
9 Correct 2 ms 2256 KB Output is correct
10 Correct 2 ms 2256 KB Output is correct
11 Correct 1 ms 720 KB Output is correct
12 Correct 4 ms 2768 KB Output is correct
13 Correct 3 ms 2640 KB Output is correct
14 Correct 4 ms 2896 KB Output is correct
15 Correct 4 ms 2896 KB Output is correct
16 Correct 3 ms 2896 KB Output is correct
17 Correct 4 ms 2896 KB Output is correct
18 Correct 2 ms 2256 KB Output is correct
19 Correct 2 ms 2256 KB Output is correct
20 Correct 2 ms 2256 KB Output is correct
21 Correct 2 ms 2256 KB Output is correct
22 Correct 0 ms 336 KB Output is correct
23 Correct 2 ms 2256 KB Output is correct
24 Correct 2 ms 2256 KB Output is correct
25 Correct 4 ms 2768 KB Output is correct
26 Correct 4 ms 2844 KB Output is correct
27 Correct 4 ms 2896 KB Output is correct
28 Correct 2 ms 2256 KB Output is correct
29 Correct 2 ms 2256 KB Output is correct
30 Correct 4 ms 2768 KB Output is correct
31 Correct 4 ms 2896 KB Output is correct
32 Correct 4 ms 2896 KB Output is correct
33 Correct 2 ms 2256 KB Output is correct
34 Correct 2 ms 2256 KB Output is correct
35 Correct 1 ms 1360 KB Output is correct
36 Correct 3 ms 2768 KB Output is correct
37 Correct 3 ms 2640 KB Output is correct
38 Correct 4 ms 2896 KB Output is correct
39 Correct 4 ms 2896 KB Output is correct
40 Correct 4 ms 2896 KB Output is correct
41 Correct 4 ms 2896 KB Output is correct
42 Correct 2 ms 2256 KB Output is correct
43 Correct 2 ms 2304 KB Output is correct
44 Correct 2 ms 2256 KB Output is correct
45 Correct 2 ms 2256 KB Output is correct
46 Correct 155 ms 99948 KB Output is correct
47 Correct 262 ms 158228 KB Output is correct
48 Correct 254 ms 158016 KB Output is correct
49 Correct 333 ms 172288 KB Output is correct
50 Correct 324 ms 172356 KB Output is correct
51 Correct 328 ms 172332 KB Output is correct
52 Correct 326 ms 172340 KB Output is correct
53 Correct 107 ms 129060 KB Output is correct
54 Correct 115 ms 129216 KB Output is correct
55 Correct 106 ms 129100 KB Output is correct
56 Correct 126 ms 129100 KB Output is correct
57 Correct 262 ms 158044 KB Output is correct
58 Correct 315 ms 172364 KB Output is correct
59 Correct 320 ms 172396 KB Output is correct
60 Correct 108 ms 129148 KB Output is correct
61 Correct 110 ms 129152 KB Output is correct
62 Correct 266 ms 158012 KB Output is correct
63 Correct 328 ms 172496 KB Output is correct
64 Correct 322 ms 172316 KB Output is correct
65 Correct 113 ms 129068 KB Output is correct
66 Correct 107 ms 129096 KB Output is correct
67 Correct 246 ms 152268 KB Output is correct
68 Correct 263 ms 158136 KB Output is correct
69 Correct 268 ms 158228 KB Output is correct
70 Correct 325 ms 172404 KB Output is correct
71 Correct 330 ms 172372 KB Output is correct
72 Correct 322 ms 172348 KB Output is correct
73 Correct 320 ms 172392 KB Output is correct
74 Correct 112 ms 129176 KB Output is correct
75 Correct 114 ms 129068 KB Output is correct
76 Correct 111 ms 129140 KB Output is correct
77 Correct 121 ms 129116 KB Output is correct
78 Correct 1140 ms 156928 KB Output is correct
79 Correct 1563 ms 158080 KB Output is correct
80 Correct 1519 ms 158080 KB Output is correct
81 Correct 1602 ms 172356 KB Output is correct
82 Correct 1550 ms 172304 KB Output is correct
83 Correct 1513 ms 172344 KB Output is correct
84 Correct 1493 ms 172328 KB Output is correct
85 Correct 1216 ms 129056 KB Output is correct
86 Correct 1055 ms 129124 KB Output is correct
87 Correct 1093 ms 129068 KB Output is correct
88 Correct 1119 ms 129124 KB Output is correct
89 Correct 1151 ms 129084 KB Output is correct
90 Correct 1170 ms 129096 KB Output is correct
91 Correct 0 ms 336 KB Output is correct
92 Correct 2 ms 2256 KB Output is correct
93 Correct 2 ms 2256 KB Output is correct
94 Correct 257 ms 158020 KB Output is correct
95 Correct 332 ms 172372 KB Output is correct
96 Correct 316 ms 172392 KB Output is correct
97 Correct 109 ms 129124 KB Output is correct
98 Correct 107 ms 129124 KB Output is correct
99 Correct 259 ms 158088 KB Output is correct
100 Correct 318 ms 172380 KB Output is correct
101 Correct 310 ms 172348 KB Output is correct
102 Correct 137 ms 129148 KB Output is correct
103 Correct 109 ms 129092 KB Output is correct
104 Correct 3 ms 2768 KB Output is correct
105 Correct 4 ms 2896 KB Output is correct
106 Correct 4 ms 2896 KB Output is correct
107 Correct 2 ms 2256 KB Output is correct
108 Correct 2 ms 2256 KB Output is correct
109 Correct 3 ms 2768 KB Output is correct
110 Correct 4 ms 2896 KB Output is correct
111 Correct 4 ms 2940 KB Output is correct
112 Correct 2 ms 2372 KB Output is correct
113 Correct 2 ms 2256 KB Output is correct
114 Correct 293 ms 34872 KB Output is correct
115 Correct 1059 ms 158072 KB Output is correct
116 Correct 1045 ms 158104 KB Output is correct
117 Correct 1274 ms 172328 KB Output is correct
118 Correct 1190 ms 172524 KB Output is correct
119 Correct 1176 ms 172360 KB Output is correct
120 Correct 1218 ms 172376 KB Output is correct
121 Correct 900 ms 129144 KB Output is correct
122 Correct 972 ms 129148 KB Output is correct
123 Correct 990 ms 129108 KB Output is correct
124 Correct 891 ms 129172 KB Output is correct
125 Correct 260 ms 158100 KB Output is correct
126 Correct 370 ms 172372 KB Output is correct
127 Correct 324 ms 172360 KB Output is correct
128 Correct 135 ms 129052 KB Output is correct
129 Correct 111 ms 129096 KB Output is correct
130 Correct 286 ms 152200 KB Output is correct
131 Correct 258 ms 158092 KB Output is correct
132 Correct 259 ms 158188 KB Output is correct
133 Correct 324 ms 172412 KB Output is correct
134 Correct 328 ms 172332 KB Output is correct
135 Correct 334 ms 172328 KB Output is correct
136 Correct 321 ms 172364 KB Output is correct
137 Correct 114 ms 129160 KB Output is correct
138 Correct 109 ms 129120 KB Output is correct
139 Correct 108 ms 129152 KB Output is correct
140 Correct 108 ms 129076 KB Output is correct
141 Correct 3 ms 2768 KB Output is correct
142 Correct 4 ms 2896 KB Output is correct
143 Correct 4 ms 2896 KB Output is correct
144 Correct 2 ms 2256 KB Output is correct
145 Correct 2 ms 2256 KB Output is correct
146 Correct 1 ms 1360 KB Output is correct
147 Correct 3 ms 2768 KB Output is correct
148 Correct 3 ms 2640 KB Output is correct
149 Correct 4 ms 2896 KB Output is correct
150 Correct 4 ms 2896 KB Output is correct
151 Correct 4 ms 2896 KB Output is correct
152 Correct 4 ms 2896 KB Output is correct
153 Correct 2 ms 2256 KB Output is correct
154 Correct 2 ms 2256 KB Output is correct
155 Correct 2 ms 2256 KB Output is correct
156 Correct 2 ms 2256 KB Output is correct
157 Correct 1092 ms 139380 KB Output is correct
158 Correct 1421 ms 158020 KB Output is correct
159 Correct 1380 ms 158212 KB Output is correct
160 Correct 1562 ms 172400 KB Output is correct
161 Correct 1452 ms 172288 KB Output is correct
162 Correct 1454 ms 172328 KB Output is correct
163 Correct 1437 ms 172372 KB Output is correct
164 Correct 1029 ms 129072 KB Output is correct
165 Correct 1061 ms 129096 KB Output is correct
166 Correct 1067 ms 129096 KB Output is correct
167 Correct 1118 ms 129168 KB Output is correct
168 Correct 0 ms 208 KB Output is correct
169 Correct 870 ms 51608 KB Output is correct
170 Correct 1630 ms 158040 KB Output is correct
171 Correct 1679 ms 158060 KB Output is correct
172 Correct 1732 ms 172280 KB Output is correct
173 Correct 1710 ms 172280 KB Output is correct
174 Correct 1739 ms 172372 KB Output is correct
175 Correct 1541 ms 172424 KB Output is correct
176 Correct 1109 ms 129068 KB Output is correct
177 Correct 1051 ms 129068 KB Output is correct
178 Correct 1022 ms 129152 KB Output is correct
179 Correct 1073 ms 129152 KB Output is correct