Submission #819885

# Submission time Handle Problem Language Result Execution time Memory
819885 2023-08-10T14:55:04 Z finn__ Radio Towers (IOI22_towers) C++17
100 / 100
1134 ms 48092 KB
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;

template <typename T, size_t L>
struct max_segtree
{
    T t[L << 1];

    max_segtree() { fill(t, t + (L << 1), numeric_limits<T>::min() / 4); }

    void update(size_t i, T x)
    {
        i += L;
        t[i] = max(t[i], x);
        while (i >>= 1)
            t[i] = max(t[i << 1], t[i << 1 | 1]);
    }

    T range_max(size_t i, size_t j)
    {
        i += L, j += L;
        T x = numeric_limits<T>::min() / 4;

        while (i <= j)
        {
            if (i & 1)
                x = max(x, t[i++]);
            if (!(j & 1))
                x = max(x, t[j--]);
            i >>= 1;
            j >>= 1;
        }

        return x;
    }
};

template <typename T, size_t L>
struct min_segtree
{
    T t[L << 1];

    min_segtree() { fill(t, t + (L << 1), numeric_limits<T>::max() / 4); }

    void update(size_t i, T x)
    {
        i += L;
        t[i] = min(t[i], x);
        while (i >>= 1)
            t[i] = min(t[i << 1], t[i << 1 | 1]);
    }

    T range_min(size_t i, size_t j)
    {
        i += L, j += L;
        T x = numeric_limits<T>::max() / 4;

        while (i <= j)
        {
            if (i & 1)
                x = min(x, t[i++]);
            if (!(j & 1))
                x = min(x, t[j--]);
            i >>= 1;
            j >>= 1;
        }

        return x;
    }

    size_t min_index_r(size_t i, size_t j, T x, size_t k = 1, size_t a = 0, size_t b = L - 1)
    {
        if (b < i || a > j)
            return SIZE_MAX;
        if (i <= a && b <= j)
        {
            if (t[k] != x)
                return SIZE_MAX;

            while (a != b)
            {
                if (t[k << 1] == x)
                    k = k << 1, b = (a + b) >> 1;
                else
                    k = k << 1 | 1, a = ((a + b) >> 1) + 1;
            }

            return a;
        }

        size_t y = min_index_r(i, j, x, k << 1, a, (a + b) >> 1);
        if (y != SIZE_MAX)
            return y;
        return min_index_r(i, j, x, k << 1 | 1, ((a + b) >> 1) + 1, b);
    }

    size_t min_index(size_t i, size_t j)
    {
        return min_index_r(i, j, range_min(i, j));
    }
};

template <typename T, size_t L>
struct left_diff_segtree
{
    struct node
    {
        T diff, max_val, min_val;
        node() { diff = numeric_limits<T>::min() / 4, max_val = numeric_limits<T>::min() / 4, min_val = numeric_limits<T>::max() / 4; }
        node(T diff, T max_val, T min_val) { this->diff = diff, this->max_val = max_val, this->min_val = min_val; }
    };

    node t[L << 1];

    node combine(node a, node b)
    {
        return node(max(a.diff, max(b.diff, b.max_val - a.min_val)),
                    max(a.max_val, b.max_val),
                    min(a.min_val, b.min_val));
    }

    void update(size_t i, T x)
    {
        i += L;
        t[i].diff = 0;
        t[i].min_val = t[i].max_val = x;
        while (i >>= 1)
            t[i] = combine(t[i << 1], t[i << 1 | 1]);
    }

    T max_diff(size_t i, size_t j)
    {
        i += L, j += L;
        node x(numeric_limits<T>::min() / 4, numeric_limits<T>::min() / 4, numeric_limits<T>::max() / 4),
            y(numeric_limits<T>::min() / 4, numeric_limits<T>::min() / 4, numeric_limits<T>::max() / 4);

        while (i <= j)
        {
            if (i & 1)
                x = combine(x, t[i++]);
            if (!(j & 1))
                y = combine(t[j--], y);
            i >>= 1;
            j >>= 1;
        }

        return combine(x, y).diff;
    }
};

template <typename T, size_t L>
struct right_diff_segtree
{
    struct node
    {
        T diff, max_val, min_val;
        node() { diff = numeric_limits<T>::min() / 4, max_val = numeric_limits<T>::min() / 4, min_val = numeric_limits<T>::max() / 4; }
        node(T diff, T max_val, T min_val) { this->diff = diff, this->max_val = max_val, this->min_val = min_val; }
    };

    node t[L << 1];

    node combine(node a, node b)
    {
        return node(max(a.diff, max(b.diff, a.max_val - b.min_val)),
                    max(a.max_val, b.max_val),
                    min(a.min_val, b.min_val));
    }

    void update(size_t i, T x)
    {
        i += L;
        t[i].diff = 0;
        t[i].min_val = t[i].max_val = x;
        while (i >>= 1)
            t[i] = combine(t[i << 1], t[i << 1 | 1]);
    }

    T max_diff(size_t i, size_t j)
    {
        i += L, j += L;
        node x(numeric_limits<T>::min() / 4, numeric_limits<T>::min() / 4, numeric_limits<T>::max() / 4),
            y(numeric_limits<T>::min() / 4, numeric_limits<T>::min() / 4, numeric_limits<T>::max() / 4);

        while (i <= j)
        {
            if (i & 1)
                x = combine(x, t[i++]);
            if (!(j & 1))
                y = combine(t[j--], y);
            i >>= 1;
            j >>= 1;
        }

        return combine(x, y).diff;
    }
};

struct node
{
    uint32_t l, r, s;
};

constexpr size_t N = 100000, M = 4000000, L = 1 << 17;

node tree[M];
uint32_t roots[N];
vector<int64_t> delta_coords;
size_t n, left_greater[N], left_smaller[N], right_greater[N], right_smaller[N], num_nodes;
int64_t h[N];

max_segtree<int64_t, L> hmax;
min_segtree<int64_t, L> hmin;
left_diff_segtree<int64_t, L> ltree;
right_diff_segtree<int64_t, L> rtree;

uint32_t incr(size_t i, uint32_t x, size_t k, size_t a = 0, size_t b = L - 1)
{
    uint32_t new_node = num_nodes++;
    if (a == b)
    {
        tree[new_node].s = tree[k].s + x;
        return new_node;
    }

    if (i <= (a + b) >> 1)
    {
        tree[new_node].r = tree[k].r;
        tree[new_node].l = incr(i, x, tree[k].l, a, (a + b) >> 1);
    }
    else
    {
        tree[new_node].l = tree[k].l;
        tree[new_node].r = incr(i, x, tree[k].r, ((a + b) >> 1) + 1, b);
    }

    tree[new_node].s = tree[tree[new_node].l].s + tree[tree[new_node].r].s;
    return new_node;
}

uint32_t range_sum(size_t i, size_t j, size_t k, size_t a = 0, size_t b = L - 1)
{
    if (b < i || a > j)
        return 0;
    if (i <= a && b <= j)
        return tree[k].s;
    return range_sum(i, j, tree[k].l, a, (a + b) >> 1) +
           range_sum(i, j, tree[k].r, ((a + b) >> 1) + 1, b);
}

size_t leftmost_nonzero(size_t i, size_t j, size_t k, size_t a = 0, size_t b = L - 1)
{
    if (b < i || a > j)
        return SIZE_MAX;
    if (i <= a && b <= j)
    {
        if (!tree[k].s)
            return SIZE_MAX;
        while (a != b)
        {
            if (tree[tree[k].l].s)
                k = tree[k].l, b = (a + b) >> 1;
            else
                k = tree[k].r, a = ((a + b) >> 1) + 1;
        }
        return a;
    }

    size_t y = leftmost_nonzero(i, j, tree[k].l, a, (a + b) >> 1);
    if (y != SIZE_MAX)
        return y;
    return leftmost_nonzero(i, j, tree[k].r, ((a + b) >> 1) + 1, b);
}

size_t rightmost_nonzero(size_t i, size_t j, size_t k, size_t a = 0, size_t b = L - 1)
{
    if (b < i || a > j)
        return SIZE_MAX;
    if (i <= a && b <= j)
    {
        if (!tree[k].s)
            return SIZE_MAX;
        while (a != b)
        {
            if (tree[tree[k].r].s)
                k = tree[k].r, a = ((a + b) >> 1) + 1;
            else
                k = tree[k].l, b = (a + b) >> 1;
        }
        return a;
    }

    size_t y = rightmost_nonzero(i, j, tree[k].r, ((a + b) >> 1) + 1, b);
    if (y != SIZE_MAX)
        return y;
    return rightmost_nonzero(i, j, tree[k].l, a, (a + b) >> 1);
}

uint32_t get_root(int64_t delta)
{
    return roots[upper_bound(delta_coords.begin(), delta_coords.end(), delta, greater<int64_t>()) - delta_coords.begin() - 1];
}

void init(int n_, vector<int> h_)
{
    n = n_;
    for (size_t i = 0; i < n; ++i)
        h[i] = h_[i];
    {
        stack<size_t> s;

        for (size_t i = 0; i < n; ++i)
        {
            while (!s.empty() && h[s.top()] < h[i])
                s.pop();
            left_greater[i] = !s.empty() ? s.top() : SIZE_MAX;
            s.push(i);
        }

        while (!s.empty())
            s.pop();

        for (size_t i = 0; i < n; ++i)
        {
            while (!s.empty() && h[s.top()] > h[i])
                s.pop();
            left_smaller[i] = !s.empty() ? s.top() : SIZE_MAX;
            s.push(i);
        }

        while (!s.empty())
            s.pop();

        for (size_t i = n - 1; i < n; --i)
        {
            while (!s.empty() && h[s.top()] < h[i])
                s.pop();
            right_greater[i] = !s.empty() ? s.top() : SIZE_MAX;
            s.push(i);
        }

        while (!s.empty())
            s.pop();

        for (size_t i = n - 1; i < n; --i)
        {
            while (!s.empty() && h[s.top()] > h[i])
                s.pop();
            right_smaller[i] = !s.empty() ? s.top() : SIZE_MAX;
            s.push(i);
        }
    }

    for (size_t i = 0; i < n; ++i)
    {
        hmax.update(i, h[i]), hmin.update(i, h[i]);
        ltree.update(i, h[i]);
        rtree.update(i, h[i]);
    }

    vector<pair<int64_t, size_t>> delta;
    for (size_t i = 0; i < n; ++i)
    {
        int64_t d = INT64_MAX;
        if (left_smaller[i] != SIZE_MAX)
            d = min(d, hmax.range_max(left_smaller[i] + 1, i - 1));
        if (right_smaller[i] != SIZE_MAX)
            d = min(d, hmax.range_max(i + 1, right_smaller[i] - 1));
        if (left_smaller[i] == SIZE_MAX && right_smaller[i] == SIZE_MAX)
            delta.emplace_back(INT64_MAX, i);
        else if (d != INT64_MIN)
            delta.emplace_back((d - h[i]), i);
    }
    sort(delta.begin(), delta.end(), greater<pair<int64_t, size_t>>());

    uint32_t curr_root = 1;
    for (size_t i = L - 1; i; --i)
        tree[i].l = i << 1, tree[i].r = i << 1 | 1;
    num_nodes = L << 1;

    for (size_t i = 0, k = 0; i < delta.size();)
    {
        size_t j = i;
        while (j < delta.size() && delta[j].first == delta[i].first)
            curr_root = incr(delta[j].second, 1, curr_root), ++j;
        roots[k] = curr_root;
        delta_coords.push_back(delta[i].first);
        i = j;
        ++k;
    }
}

size_t left_intermediate(size_t i, int64_t d)
{
    if (!i || hmax.range_max(0, i - 1) < h[i] + d)
        return SIZE_MAX;
    size_t a = 0, b = i - 1;
    while (a < b)
    {
        size_t const mid = (a + b + 1) >> 1;
        if (hmax.range_max(mid, i - 1) >= h[i] + d)
            a = mid;
        else
            b = mid - 1;
    }
    return a;
}

size_t right_intermediate(size_t i, int64_t d)
{
    if (i == n - 1 || hmax.range_max(i + 1, n - 1) < h[i] + d)
        return SIZE_MAX;
    size_t a = i + 1, b = n - 1;
    while (a < b)
    {
        size_t const mid = (a + b) >> 1;
        if (hmax.range_max(i + 1, mid) >= h[i] + d)
            b = mid;
        else
            a = mid + 1;
    }
    return a;
}

bool match_left(size_t i, size_t l, int64_t d)
{
    size_t j = left_intermediate(i, d);
    if (j == SIZE_MAX || j <= l)
        return 0;
    return ltree.max_diff(l, j) >= d;
}

bool match_right(size_t i, size_t r, int64_t d)
{
    size_t j = right_intermediate(i, d);
    if (j == SIZE_MAX || j >= r)
        return 0;
    return rtree.max_diff(j, r) >= d;
}

int max_towers(int l, int r, int d)
{
    uint32_t rt = get_root(d);
    uint32_t y = range_sum(l, r, rt);
    if (!y)
    {
        size_t smallest = hmin.min_index(l, r);
        return 1 + (match_left(smallest, l, d) || match_right(smallest, r, d));
    }
    else
    {
        size_t u = leftmost_nonzero(l, r, rt),
               v = rightmost_nonzero(l, r, rt);
        return y + match_left(u, l, d) + match_right(v, r, d);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 381 ms 35840 KB Output is correct
2 Correct 900 ms 47856 KB Output is correct
3 Correct 915 ms 47768 KB Output is correct
4 Correct 917 ms 47956 KB Output is correct
5 Correct 833 ms 48064 KB Output is correct
6 Correct 926 ms 48004 KB Output is correct
7 Correct 891 ms 48084 KB Output is correct
8 Correct 7 ms 18256 KB Output is correct
9 Correct 9 ms 18896 KB Output is correct
10 Correct 8 ms 18768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 18384 KB Output is correct
2 Correct 9 ms 18896 KB Output is correct
3 Correct 9 ms 18860 KB Output is correct
4 Correct 8 ms 18896 KB Output is correct
5 Correct 9 ms 18820 KB Output is correct
6 Correct 8 ms 18896 KB Output is correct
7 Correct 10 ms 18896 KB Output is correct
8 Correct 10 ms 18832 KB Output is correct
9 Correct 9 ms 18896 KB Output is correct
10 Correct 9 ms 18896 KB Output is correct
11 Correct 10 ms 18904 KB Output is correct
12 Correct 8 ms 18256 KB Output is correct
13 Correct 9 ms 18816 KB Output is correct
14 Correct 9 ms 18768 KB Output is correct
15 Correct 10 ms 18908 KB Output is correct
16 Correct 9 ms 18896 KB Output is correct
17 Correct 11 ms 18896 KB Output is correct
18 Correct 9 ms 18808 KB Output is correct
19 Correct 8 ms 18896 KB Output is correct
20 Correct 9 ms 18896 KB Output is correct
21 Correct 9 ms 18896 KB Output is correct
22 Correct 9 ms 18896 KB Output is correct
23 Correct 8 ms 18896 KB Output is correct
24 Correct 8 ms 18768 KB Output is correct
25 Correct 8 ms 18512 KB Output is correct
26 Correct 9 ms 18896 KB Output is correct
27 Correct 11 ms 18904 KB Output is correct
28 Correct 9 ms 18784 KB Output is correct
29 Correct 8 ms 18896 KB Output is correct
30 Correct 9 ms 18908 KB Output is correct
31 Correct 9 ms 18896 KB Output is correct
32 Correct 9 ms 18884 KB Output is correct
33 Correct 9 ms 18792 KB Output is correct
34 Correct 9 ms 18768 KB Output is correct
35 Correct 8 ms 18896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 18384 KB Output is correct
2 Correct 9 ms 18896 KB Output is correct
3 Correct 9 ms 18860 KB Output is correct
4 Correct 8 ms 18896 KB Output is correct
5 Correct 9 ms 18820 KB Output is correct
6 Correct 8 ms 18896 KB Output is correct
7 Correct 10 ms 18896 KB Output is correct
8 Correct 10 ms 18832 KB Output is correct
9 Correct 9 ms 18896 KB Output is correct
10 Correct 9 ms 18896 KB Output is correct
11 Correct 10 ms 18904 KB Output is correct
12 Correct 8 ms 18256 KB Output is correct
13 Correct 9 ms 18816 KB Output is correct
14 Correct 9 ms 18768 KB Output is correct
15 Correct 10 ms 18908 KB Output is correct
16 Correct 9 ms 18896 KB Output is correct
17 Correct 11 ms 18896 KB Output is correct
18 Correct 9 ms 18808 KB Output is correct
19 Correct 8 ms 18896 KB Output is correct
20 Correct 9 ms 18896 KB Output is correct
21 Correct 9 ms 18896 KB Output is correct
22 Correct 9 ms 18896 KB Output is correct
23 Correct 8 ms 18896 KB Output is correct
24 Correct 8 ms 18768 KB Output is correct
25 Correct 8 ms 18512 KB Output is correct
26 Correct 9 ms 18896 KB Output is correct
27 Correct 11 ms 18904 KB Output is correct
28 Correct 9 ms 18784 KB Output is correct
29 Correct 8 ms 18896 KB Output is correct
30 Correct 9 ms 18908 KB Output is correct
31 Correct 9 ms 18896 KB Output is correct
32 Correct 9 ms 18884 KB Output is correct
33 Correct 9 ms 18792 KB Output is correct
34 Correct 9 ms 18768 KB Output is correct
35 Correct 8 ms 18896 KB Output is correct
36 Correct 55 ms 37324 KB Output is correct
37 Correct 89 ms 47812 KB Output is correct
38 Correct 89 ms 47820 KB Output is correct
39 Correct 85 ms 47804 KB Output is correct
40 Correct 88 ms 47760 KB Output is correct
41 Correct 80 ms 47760 KB Output is correct
42 Correct 82 ms 47764 KB Output is correct
43 Correct 60 ms 47944 KB Output is correct
44 Correct 60 ms 48064 KB Output is correct
45 Correct 63 ms 47856 KB Output is correct
46 Correct 63 ms 47908 KB Output is correct
47 Correct 86 ms 47744 KB Output is correct
48 Correct 90 ms 47816 KB Output is correct
49 Correct 91 ms 47768 KB Output is correct
50 Correct 66 ms 48064 KB Output is correct
51 Correct 65 ms 47996 KB Output is correct
52 Correct 83 ms 47820 KB Output is correct
53 Correct 83 ms 47860 KB Output is correct
54 Correct 81 ms 47800 KB Output is correct
55 Correct 60 ms 48088 KB Output is correct
56 Correct 72 ms 47860 KB Output is correct
57 Correct 80 ms 46852 KB Output is correct
58 Correct 83 ms 47772 KB Output is correct
59 Correct 84 ms 47756 KB Output is correct
60 Correct 91 ms 47756 KB Output is correct
61 Correct 88 ms 47816 KB Output is correct
62 Correct 82 ms 47756 KB Output is correct
63 Correct 80 ms 47760 KB Output is correct
64 Correct 60 ms 48004 KB Output is correct
65 Correct 59 ms 48072 KB Output is correct
66 Correct 64 ms 47868 KB Output is correct
67 Correct 67 ms 48028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 779 ms 47560 KB Output is correct
2 Correct 1010 ms 47804 KB Output is correct
3 Correct 1069 ms 47756 KB Output is correct
4 Correct 1078 ms 47756 KB Output is correct
5 Correct 1053 ms 47756 KB Output is correct
6 Correct 1010 ms 47808 KB Output is correct
7 Correct 1068 ms 47848 KB Output is correct
8 Correct 991 ms 47960 KB Output is correct
9 Correct 984 ms 48064 KB Output is correct
10 Correct 923 ms 47980 KB Output is correct
11 Correct 984 ms 47940 KB Output is correct
12 Correct 914 ms 47948 KB Output is correct
13 Correct 951 ms 48092 KB Output is correct
14 Correct 7 ms 18256 KB Output is correct
15 Correct 9 ms 18896 KB Output is correct
16 Correct 9 ms 18896 KB Output is correct
17 Correct 100 ms 47832 KB Output is correct
18 Correct 87 ms 47764 KB Output is correct
19 Correct 81 ms 47800 KB Output is correct
20 Correct 66 ms 48056 KB Output is correct
21 Correct 66 ms 48008 KB Output is correct
22 Correct 100 ms 47764 KB Output is correct
23 Correct 91 ms 47788 KB Output is correct
24 Correct 89 ms 47820 KB Output is correct
25 Correct 66 ms 48072 KB Output is correct
26 Correct 66 ms 47876 KB Output is correct
27 Correct 9 ms 18896 KB Output is correct
28 Correct 9 ms 18896 KB Output is correct
29 Correct 9 ms 18824 KB Output is correct
30 Correct 8 ms 18896 KB Output is correct
31 Correct 9 ms 18768 KB Output is correct
32 Correct 9 ms 18868 KB Output is correct
33 Correct 9 ms 18896 KB Output is correct
34 Correct 12 ms 18804 KB Output is correct
35 Correct 9 ms 18768 KB Output is correct
36 Correct 10 ms 18852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 255 ms 25348 KB Output is correct
2 Correct 789 ms 47800 KB Output is correct
3 Correct 819 ms 47804 KB Output is correct
4 Correct 670 ms 47808 KB Output is correct
5 Correct 821 ms 47796 KB Output is correct
6 Correct 845 ms 47788 KB Output is correct
7 Correct 757 ms 47824 KB Output is correct
8 Correct 802 ms 47948 KB Output is correct
9 Correct 743 ms 48084 KB Output is correct
10 Correct 608 ms 47796 KB Output is correct
11 Correct 725 ms 48052 KB Output is correct
12 Correct 83 ms 47744 KB Output is correct
13 Correct 79 ms 47852 KB Output is correct
14 Correct 80 ms 47828 KB Output is correct
15 Correct 66 ms 48084 KB Output is correct
16 Correct 71 ms 47928 KB Output is correct
17 Correct 88 ms 46908 KB Output is correct
18 Correct 88 ms 47820 KB Output is correct
19 Correct 92 ms 47804 KB Output is correct
20 Correct 82 ms 47820 KB Output is correct
21 Correct 86 ms 47936 KB Output is correct
22 Correct 81 ms 47820 KB Output is correct
23 Correct 79 ms 47768 KB Output is correct
24 Correct 67 ms 47980 KB Output is correct
25 Correct 68 ms 48088 KB Output is correct
26 Correct 65 ms 47856 KB Output is correct
27 Correct 66 ms 48032 KB Output is correct
28 Correct 9 ms 18896 KB Output is correct
29 Correct 9 ms 18904 KB Output is correct
30 Correct 9 ms 18828 KB Output is correct
31 Correct 8 ms 18896 KB Output is correct
32 Correct 9 ms 18768 KB Output is correct
33 Correct 8 ms 18512 KB Output is correct
34 Correct 9 ms 18868 KB Output is correct
35 Correct 9 ms 18824 KB Output is correct
36 Correct 9 ms 18896 KB Output is correct
37 Correct 9 ms 18896 KB Output is correct
38 Correct 9 ms 18892 KB Output is correct
39 Correct 8 ms 18908 KB Output is correct
40 Correct 9 ms 18896 KB Output is correct
41 Correct 9 ms 18784 KB Output is correct
42 Correct 10 ms 18768 KB Output is correct
43 Correct 9 ms 18896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 18384 KB Output is correct
2 Correct 9 ms 18896 KB Output is correct
3 Correct 9 ms 18860 KB Output is correct
4 Correct 8 ms 18896 KB Output is correct
5 Correct 9 ms 18820 KB Output is correct
6 Correct 8 ms 18896 KB Output is correct
7 Correct 10 ms 18896 KB Output is correct
8 Correct 10 ms 18832 KB Output is correct
9 Correct 9 ms 18896 KB Output is correct
10 Correct 9 ms 18896 KB Output is correct
11 Correct 10 ms 18904 KB Output is correct
12 Correct 8 ms 18256 KB Output is correct
13 Correct 9 ms 18816 KB Output is correct
14 Correct 9 ms 18768 KB Output is correct
15 Correct 10 ms 18908 KB Output is correct
16 Correct 9 ms 18896 KB Output is correct
17 Correct 11 ms 18896 KB Output is correct
18 Correct 9 ms 18808 KB Output is correct
19 Correct 8 ms 18896 KB Output is correct
20 Correct 9 ms 18896 KB Output is correct
21 Correct 9 ms 18896 KB Output is correct
22 Correct 9 ms 18896 KB Output is correct
23 Correct 8 ms 18896 KB Output is correct
24 Correct 8 ms 18768 KB Output is correct
25 Correct 8 ms 18512 KB Output is correct
26 Correct 9 ms 18896 KB Output is correct
27 Correct 11 ms 18904 KB Output is correct
28 Correct 9 ms 18784 KB Output is correct
29 Correct 8 ms 18896 KB Output is correct
30 Correct 9 ms 18908 KB Output is correct
31 Correct 9 ms 18896 KB Output is correct
32 Correct 9 ms 18884 KB Output is correct
33 Correct 9 ms 18792 KB Output is correct
34 Correct 9 ms 18768 KB Output is correct
35 Correct 8 ms 18896 KB Output is correct
36 Correct 55 ms 37324 KB Output is correct
37 Correct 89 ms 47812 KB Output is correct
38 Correct 89 ms 47820 KB Output is correct
39 Correct 85 ms 47804 KB Output is correct
40 Correct 88 ms 47760 KB Output is correct
41 Correct 80 ms 47760 KB Output is correct
42 Correct 82 ms 47764 KB Output is correct
43 Correct 60 ms 47944 KB Output is correct
44 Correct 60 ms 48064 KB Output is correct
45 Correct 63 ms 47856 KB Output is correct
46 Correct 63 ms 47908 KB Output is correct
47 Correct 86 ms 47744 KB Output is correct
48 Correct 90 ms 47816 KB Output is correct
49 Correct 91 ms 47768 KB Output is correct
50 Correct 66 ms 48064 KB Output is correct
51 Correct 65 ms 47996 KB Output is correct
52 Correct 83 ms 47820 KB Output is correct
53 Correct 83 ms 47860 KB Output is correct
54 Correct 81 ms 47800 KB Output is correct
55 Correct 60 ms 48088 KB Output is correct
56 Correct 72 ms 47860 KB Output is correct
57 Correct 80 ms 46852 KB Output is correct
58 Correct 83 ms 47772 KB Output is correct
59 Correct 84 ms 47756 KB Output is correct
60 Correct 91 ms 47756 KB Output is correct
61 Correct 88 ms 47816 KB Output is correct
62 Correct 82 ms 47756 KB Output is correct
63 Correct 80 ms 47760 KB Output is correct
64 Correct 60 ms 48004 KB Output is correct
65 Correct 59 ms 48072 KB Output is correct
66 Correct 64 ms 47868 KB Output is correct
67 Correct 67 ms 48028 KB Output is correct
68 Correct 779 ms 47560 KB Output is correct
69 Correct 1010 ms 47804 KB Output is correct
70 Correct 1069 ms 47756 KB Output is correct
71 Correct 1078 ms 47756 KB Output is correct
72 Correct 1053 ms 47756 KB Output is correct
73 Correct 1010 ms 47808 KB Output is correct
74 Correct 1068 ms 47848 KB Output is correct
75 Correct 991 ms 47960 KB Output is correct
76 Correct 984 ms 48064 KB Output is correct
77 Correct 923 ms 47980 KB Output is correct
78 Correct 984 ms 47940 KB Output is correct
79 Correct 914 ms 47948 KB Output is correct
80 Correct 951 ms 48092 KB Output is correct
81 Correct 7 ms 18256 KB Output is correct
82 Correct 9 ms 18896 KB Output is correct
83 Correct 9 ms 18896 KB Output is correct
84 Correct 100 ms 47832 KB Output is correct
85 Correct 87 ms 47764 KB Output is correct
86 Correct 81 ms 47800 KB Output is correct
87 Correct 66 ms 48056 KB Output is correct
88 Correct 66 ms 48008 KB Output is correct
89 Correct 100 ms 47764 KB Output is correct
90 Correct 91 ms 47788 KB Output is correct
91 Correct 89 ms 47820 KB Output is correct
92 Correct 66 ms 48072 KB Output is correct
93 Correct 66 ms 47876 KB Output is correct
94 Correct 9 ms 18896 KB Output is correct
95 Correct 9 ms 18896 KB Output is correct
96 Correct 9 ms 18824 KB Output is correct
97 Correct 8 ms 18896 KB Output is correct
98 Correct 9 ms 18768 KB Output is correct
99 Correct 9 ms 18868 KB Output is correct
100 Correct 9 ms 18896 KB Output is correct
101 Correct 12 ms 18804 KB Output is correct
102 Correct 9 ms 18768 KB Output is correct
103 Correct 10 ms 18852 KB Output is correct
104 Correct 823 ms 44612 KB Output is correct
105 Correct 973 ms 47772 KB Output is correct
106 Correct 1034 ms 47800 KB Output is correct
107 Correct 994 ms 47744 KB Output is correct
108 Correct 985 ms 47796 KB Output is correct
109 Correct 962 ms 47808 KB Output is correct
110 Correct 967 ms 47760 KB Output is correct
111 Correct 896 ms 48008 KB Output is correct
112 Correct 918 ms 48092 KB Output is correct
113 Correct 919 ms 47796 KB Output is correct
114 Correct 928 ms 47892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 381 ms 35840 KB Output is correct
2 Correct 900 ms 47856 KB Output is correct
3 Correct 915 ms 47768 KB Output is correct
4 Correct 917 ms 47956 KB Output is correct
5 Correct 833 ms 48064 KB Output is correct
6 Correct 926 ms 48004 KB Output is correct
7 Correct 891 ms 48084 KB Output is correct
8 Correct 7 ms 18256 KB Output is correct
9 Correct 9 ms 18896 KB Output is correct
10 Correct 8 ms 18768 KB Output is correct
11 Correct 8 ms 18384 KB Output is correct
12 Correct 9 ms 18896 KB Output is correct
13 Correct 9 ms 18860 KB Output is correct
14 Correct 8 ms 18896 KB Output is correct
15 Correct 9 ms 18820 KB Output is correct
16 Correct 8 ms 18896 KB Output is correct
17 Correct 10 ms 18896 KB Output is correct
18 Correct 10 ms 18832 KB Output is correct
19 Correct 9 ms 18896 KB Output is correct
20 Correct 9 ms 18896 KB Output is correct
21 Correct 10 ms 18904 KB Output is correct
22 Correct 8 ms 18256 KB Output is correct
23 Correct 9 ms 18816 KB Output is correct
24 Correct 9 ms 18768 KB Output is correct
25 Correct 10 ms 18908 KB Output is correct
26 Correct 9 ms 18896 KB Output is correct
27 Correct 11 ms 18896 KB Output is correct
28 Correct 9 ms 18808 KB Output is correct
29 Correct 8 ms 18896 KB Output is correct
30 Correct 9 ms 18896 KB Output is correct
31 Correct 9 ms 18896 KB Output is correct
32 Correct 9 ms 18896 KB Output is correct
33 Correct 8 ms 18896 KB Output is correct
34 Correct 8 ms 18768 KB Output is correct
35 Correct 8 ms 18512 KB Output is correct
36 Correct 9 ms 18896 KB Output is correct
37 Correct 11 ms 18904 KB Output is correct
38 Correct 9 ms 18784 KB Output is correct
39 Correct 8 ms 18896 KB Output is correct
40 Correct 9 ms 18908 KB Output is correct
41 Correct 9 ms 18896 KB Output is correct
42 Correct 9 ms 18884 KB Output is correct
43 Correct 9 ms 18792 KB Output is correct
44 Correct 9 ms 18768 KB Output is correct
45 Correct 8 ms 18896 KB Output is correct
46 Correct 55 ms 37324 KB Output is correct
47 Correct 89 ms 47812 KB Output is correct
48 Correct 89 ms 47820 KB Output is correct
49 Correct 85 ms 47804 KB Output is correct
50 Correct 88 ms 47760 KB Output is correct
51 Correct 80 ms 47760 KB Output is correct
52 Correct 82 ms 47764 KB Output is correct
53 Correct 60 ms 47944 KB Output is correct
54 Correct 60 ms 48064 KB Output is correct
55 Correct 63 ms 47856 KB Output is correct
56 Correct 63 ms 47908 KB Output is correct
57 Correct 86 ms 47744 KB Output is correct
58 Correct 90 ms 47816 KB Output is correct
59 Correct 91 ms 47768 KB Output is correct
60 Correct 66 ms 48064 KB Output is correct
61 Correct 65 ms 47996 KB Output is correct
62 Correct 83 ms 47820 KB Output is correct
63 Correct 83 ms 47860 KB Output is correct
64 Correct 81 ms 47800 KB Output is correct
65 Correct 60 ms 48088 KB Output is correct
66 Correct 72 ms 47860 KB Output is correct
67 Correct 80 ms 46852 KB Output is correct
68 Correct 83 ms 47772 KB Output is correct
69 Correct 84 ms 47756 KB Output is correct
70 Correct 91 ms 47756 KB Output is correct
71 Correct 88 ms 47816 KB Output is correct
72 Correct 82 ms 47756 KB Output is correct
73 Correct 80 ms 47760 KB Output is correct
74 Correct 60 ms 48004 KB Output is correct
75 Correct 59 ms 48072 KB Output is correct
76 Correct 64 ms 47868 KB Output is correct
77 Correct 67 ms 48028 KB Output is correct
78 Correct 779 ms 47560 KB Output is correct
79 Correct 1010 ms 47804 KB Output is correct
80 Correct 1069 ms 47756 KB Output is correct
81 Correct 1078 ms 47756 KB Output is correct
82 Correct 1053 ms 47756 KB Output is correct
83 Correct 1010 ms 47808 KB Output is correct
84 Correct 1068 ms 47848 KB Output is correct
85 Correct 991 ms 47960 KB Output is correct
86 Correct 984 ms 48064 KB Output is correct
87 Correct 923 ms 47980 KB Output is correct
88 Correct 984 ms 47940 KB Output is correct
89 Correct 914 ms 47948 KB Output is correct
90 Correct 951 ms 48092 KB Output is correct
91 Correct 7 ms 18256 KB Output is correct
92 Correct 9 ms 18896 KB Output is correct
93 Correct 9 ms 18896 KB Output is correct
94 Correct 100 ms 47832 KB Output is correct
95 Correct 87 ms 47764 KB Output is correct
96 Correct 81 ms 47800 KB Output is correct
97 Correct 66 ms 48056 KB Output is correct
98 Correct 66 ms 48008 KB Output is correct
99 Correct 100 ms 47764 KB Output is correct
100 Correct 91 ms 47788 KB Output is correct
101 Correct 89 ms 47820 KB Output is correct
102 Correct 66 ms 48072 KB Output is correct
103 Correct 66 ms 47876 KB Output is correct
104 Correct 9 ms 18896 KB Output is correct
105 Correct 9 ms 18896 KB Output is correct
106 Correct 9 ms 18824 KB Output is correct
107 Correct 8 ms 18896 KB Output is correct
108 Correct 9 ms 18768 KB Output is correct
109 Correct 9 ms 18868 KB Output is correct
110 Correct 9 ms 18896 KB Output is correct
111 Correct 12 ms 18804 KB Output is correct
112 Correct 9 ms 18768 KB Output is correct
113 Correct 10 ms 18852 KB Output is correct
114 Correct 255 ms 25348 KB Output is correct
115 Correct 789 ms 47800 KB Output is correct
116 Correct 819 ms 47804 KB Output is correct
117 Correct 670 ms 47808 KB Output is correct
118 Correct 821 ms 47796 KB Output is correct
119 Correct 845 ms 47788 KB Output is correct
120 Correct 757 ms 47824 KB Output is correct
121 Correct 802 ms 47948 KB Output is correct
122 Correct 743 ms 48084 KB Output is correct
123 Correct 608 ms 47796 KB Output is correct
124 Correct 725 ms 48052 KB Output is correct
125 Correct 83 ms 47744 KB Output is correct
126 Correct 79 ms 47852 KB Output is correct
127 Correct 80 ms 47828 KB Output is correct
128 Correct 66 ms 48084 KB Output is correct
129 Correct 71 ms 47928 KB Output is correct
130 Correct 88 ms 46908 KB Output is correct
131 Correct 88 ms 47820 KB Output is correct
132 Correct 92 ms 47804 KB Output is correct
133 Correct 82 ms 47820 KB Output is correct
134 Correct 86 ms 47936 KB Output is correct
135 Correct 81 ms 47820 KB Output is correct
136 Correct 79 ms 47768 KB Output is correct
137 Correct 67 ms 47980 KB Output is correct
138 Correct 68 ms 48088 KB Output is correct
139 Correct 65 ms 47856 KB Output is correct
140 Correct 66 ms 48032 KB Output is correct
141 Correct 9 ms 18896 KB Output is correct
142 Correct 9 ms 18904 KB Output is correct
143 Correct 9 ms 18828 KB Output is correct
144 Correct 8 ms 18896 KB Output is correct
145 Correct 9 ms 18768 KB Output is correct
146 Correct 8 ms 18512 KB Output is correct
147 Correct 9 ms 18868 KB Output is correct
148 Correct 9 ms 18824 KB Output is correct
149 Correct 9 ms 18896 KB Output is correct
150 Correct 9 ms 18896 KB Output is correct
151 Correct 9 ms 18892 KB Output is correct
152 Correct 8 ms 18908 KB Output is correct
153 Correct 9 ms 18896 KB Output is correct
154 Correct 9 ms 18784 KB Output is correct
155 Correct 10 ms 18768 KB Output is correct
156 Correct 9 ms 18896 KB Output is correct
157 Correct 823 ms 44612 KB Output is correct
158 Correct 973 ms 47772 KB Output is correct
159 Correct 1034 ms 47800 KB Output is correct
160 Correct 994 ms 47744 KB Output is correct
161 Correct 985 ms 47796 KB Output is correct
162 Correct 962 ms 47808 KB Output is correct
163 Correct 967 ms 47760 KB Output is correct
164 Correct 896 ms 48008 KB Output is correct
165 Correct 918 ms 48092 KB Output is correct
166 Correct 919 ms 47796 KB Output is correct
167 Correct 928 ms 47892 KB Output is correct
168 Correct 8 ms 18256 KB Output is correct
169 Correct 617 ms 28604 KB Output is correct
170 Correct 1059 ms 47800 KB Output is correct
171 Correct 1105 ms 47804 KB Output is correct
172 Correct 1010 ms 47848 KB Output is correct
173 Correct 1065 ms 47808 KB Output is correct
174 Correct 1064 ms 47804 KB Output is correct
175 Correct 1134 ms 47820 KB Output is correct
176 Correct 956 ms 47944 KB Output is correct
177 Correct 978 ms 48080 KB Output is correct
178 Correct 1026 ms 47876 KB Output is correct
179 Correct 917 ms 47896 KB Output is correct