Submission #635283

# Submission time Handle Problem Language Result Execution time Memory
635283 2022-08-25T21:00:39 Z tutis Radio Towers (IOI22_towers) C++17
100 / 100
2190 ms 127964 KB
#include "towers.h"

#include <bits/stdc++.h>
using namespace std;
vector<int>H;
struct ST
{
    int l, r;
    ST *left, *right;
    int mn;
    ST() {}
    vector<pair<int, int>>V;
    vector<pair<int, int>>W;
    vector<pair<int, int>>V_;
    vector<pair<int, int>>W_;
    ST(int l, int r): l(l), r(r)
    {
        if (l < r)
        {
            left = new ST(l, (l + r) / 2);
            right = new ST((l + r) / 2 + 1, r);
            mn = min(left->mn, right->mn);
        }
        else
        {
            left = right = NULL;
            mn = H[l];
        }
        {
            for (int i = l; i <= r; i++)
            {
                if (W.empty() || H[i] > W.back().first)
                    W.push_back({H[i], i});
            }
            int mm = 1.1e9;
            for (int i = l + 1; i <= r; i++)
            {
                mm = min(mm, H[i - 1]);
                if (V.empty() || H[i] - mm > V.back().first)
                    V.push_back({H[i] - mm, i});
            }
        }
        {
            for (int i = r; i >= l; i--)
            {
                if (W_.empty() || H[i] > W_.back().first)
                    W_.push_back({H[i], i});
            }
            int mm = 1.1e9;
            for (int i = r - 1; i >= l; i--)
            {
                mm = min(mm, H[i + 1]);
                if (V_.empty() || H[i] - mm > V_.back().first)
                    V_.push_back({H[i] - mm, i});
            }
        }
    }
    int get(int x, int y)
    {
        if (x <= l && r <= y)
            return mn;
        if (r < x || y < l)
            return 1.1e9;
        return min(left->get(x, y), right->get(x, y));
    }
    pair<int, int> get1(int L, int D, int mnl = 1.1e9)
    {
        if (L <= l)
        {
            int rr = -1;
            auto it = lower_bound(V.begin(), V.end(), make_pair(D, -1));
            if (it != V.end())
                rr = it->second;
            //W-mn>=D
            //W>=D+mn
            it = lower_bound(W.begin(), W.end(), make_pair(D + mnl, -1));
            if (it != W.end())
            {
                int r1 = it->second;
                if (rr == -1)
                    rr = r1;
                else
                    rr = min(rr, r1);
            }
            return {rr, mn};
        }
        if (r < L)
            return { -1, 1.1e9};
        pair<int, int> i = left->get1(L, D, mnl);
        pair<int, int> j = right->get1(L, D, min(i.second, mnl));
        j.second = min(j.second, i.second);
        if (i.first != -1)
            j.first = i.first;
        return j;
    }
    pair<int, int> get2(int R, int D, int mnl = 1.1e9)
    {
        if (R >= r)
        {
            int rr = -1;
            auto it = lower_bound(V_.begin(), V_.end(), make_pair(D, -1));
            if (it != V_.end())
                rr = it->second;
            //W-mn>=D
            //W>=D+mn
            it = lower_bound(W_.begin(), W_.end(), make_pair(D + mnl, -1));
            if (it != W_.end())
            {
                int r1 = it->second;
                if (rr == -1)
                    rr = r1;
                else
                    rr = max(rr, r1);
            }
            return {rr, mn};
        }
        if (l > R)
            return { -1, 1.1e9};
        pair<int, int> i = right->get2(R, D, mnl);
        pair<int, int> j = left->get2(R, D, min(i.second, mnl));
        j.second = min(j.second, i.second);
        if (i.first != -1)
            j.first = i.first;
        return j;
    }
} medis;
vector<vector<pair<int, int>>>Fl, Fr;
int N;
vector<int>prv;
vector<int>nxt;
void init(int N_, vector<int> H_) {
    N = N_;
    H = H_;
    prv = vector<int>(N, -1);
    nxt = vector<int>(N, N + 1);
    {
        vector<int>A;
        for (int i = 0; i < N; i++)
        {
            while (!A.empty() && H[A.back()] <= H[i])
                A.pop_back();
            if (!A.empty())
                prv[i] = A.back();
            A.push_back(i);
        }
        A.clear();
        for (int i = N - 1; i >= 0; i--)
        {
            while (!A.empty() && H[A.back()] <= H[i])
                A.pop_back();
            if (!A.empty())
                nxt[i] = A.back();
            A.push_back(i);
        }
    }
    vector<int> p(N);
    iota(p.begin(), p.end(), 0);
    sort(p.begin(), p.end(), [&](int a, int b) {return H[a] > H[b];});
    set<int>X;
    medis = ST(0, N - 1);
    auto get = [&](int l, int r)
    {
        if (l + 1 >= r)
            return -1;
        int h = medis.get(l + 1, r - 1);
        return max(0, min(H[l] - h, H[r] - h));
    };
    map<int, vector<pair<int, int>>>L;
    map<int, vector<pair<int, int>>>R;
    auto add = [&](int l, int r, int d, int w)
    {
        R[d].push_back({r, w});
        L[d].push_back({l, w});
    };
    for (int i : p)
    {
        int r = -1, l = -1;
        auto it = X.lower_bound(i);
        if (it != X.end())
        {
            r = *it;
        }
        if (it != X.begin())
        {
            it--;
            l = *it;
        }
        X.insert(i);
        if (l == -1 || r == -1)
        {
            if (r != -1 && i + 1 < r)
                add(i, r, get(i, r), 1);
            if (l != -1 && l + 1 < i)
                add(l, i, get(l, i), 1);
        }
        else
        {
            int d = get(l, r);
            int d1 = get(i, r);
            int d2 = get(l, i);
            if (d1 >= 0 || d2 >= 0)
            {
                add(i, r, d1, 1);
                add(l, i, d2, 1);
                assert(max(d1, d2) <= d);
                add(l, r, max(d1, d2), -1);
            }
        }
    }
    Fl = vector<vector<pair<int, int>>>(N);
    Fr = vector<vector<pair<int, int>>>(N);
    for (const auto &dd : L)
    {
        int d = dd.first;
        for (pair<int, int>lw : dd.second)
            for (int i = lw.first; i < N; i |= i + 1)
            {
                if (!Fl[i].empty() && Fl[i].back().first == d)
                    Fl[i].back().second += lw.second;
                else
                    Fl[i].push_back({d, lw.second});
            }
    }
    for (const auto &dd : R)
    {
        int d = dd.first;
        for (pair<int, int>rw : dd.second)
            for (int i = rw.first; i < N; i |= i + 1)
            {
                if (!Fr[i].empty() && Fr[i].back().first == d)
                    Fr[i].back().second += rw.second;
                else
                    Fr[i].push_back({d, rw.second});
            }
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = 1; j < (int)Fl[i].size(); j++)
            Fl[i][j].second += Fl[i][j - 1].second;
        for (int j = 1; j < (int)Fr[i].size(); j++)
            Fr[i][j].second += Fr[i][j - 1].second;
    }
}
int get(int l, int r, int d)
{
    int ret = 0;
    int i = r;
    while (i >= 0)
    {
        if (!Fr[i].empty())
        {
            auto it = lower_bound(Fr[i].begin(), Fr[i].end(), make_pair(d, (int) - 1e9));
            ret += Fr[i].back().second;
            if (it != Fr[i].begin())
            {
                it--;
                ret -= it->second;
            }
        }
        i = (i & (i + 1)) - 1;
    }
    i = l - 1;
    while (i >= 0) {
        if (!Fl[i].empty())
        {
            auto it = lower_bound(Fl[i].begin(), Fl[i].end(), make_pair(d, (int) - 1e9));
            ret -= Fl[i].back().second;
            if (it != Fl[i].begin())
            {
                it--;
                ret += it->second;
            }
        }
        i = (i & (i + 1)) - 1;
    }
    return ret;
}
int max_towers(int L, int R, int D) {
    int xx = medis.get1(L, D).first;
    int yy = medis.get2(R, D).first;
    if (xx != -1 && yy != -1 && xx <= yy)
        return 2 + get(xx, yy, D);
    return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 682 ms 49796 KB Output is correct
2 Correct 1351 ms 87500 KB Output is correct
3 Correct 1400 ms 87544 KB Output is correct
4 Correct 1133 ms 87364 KB Output is correct
5 Correct 1250 ms 87376 KB Output is correct
6 Correct 1342 ms 87308 KB Output is correct
7 Correct 1308 ms 87316 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 3 ms 1728 KB Output is correct
10 Correct 3 ms 1744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 720 KB Output is correct
2 Correct 6 ms 2348 KB Output is correct
3 Correct 6 ms 2256 KB Output is correct
4 Correct 6 ms 2128 KB Output is correct
5 Correct 6 ms 2184 KB Output is correct
6 Correct 6 ms 2172 KB Output is correct
7 Correct 5 ms 2128 KB Output is correct
8 Correct 3 ms 1744 KB Output is correct
9 Correct 3 ms 1744 KB Output is correct
10 Correct 7 ms 2256 KB Output is correct
11 Correct 5 ms 2464 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 3 ms 1712 KB Output is correct
14 Correct 2 ms 1744 KB Output is correct
15 Correct 6 ms 2256 KB Output is correct
16 Correct 5 ms 2128 KB Output is correct
17 Correct 8 ms 2128 KB Output is correct
18 Correct 3 ms 1744 KB Output is correct
19 Correct 4 ms 2004 KB Output is correct
20 Correct 7 ms 2256 KB Output is correct
21 Correct 8 ms 2128 KB Output is correct
22 Correct 6 ms 2128 KB Output is correct
23 Correct 3 ms 1744 KB Output is correct
24 Correct 3 ms 1872 KB Output is correct
25 Correct 3 ms 1104 KB Output is correct
26 Correct 6 ms 2256 KB Output is correct
27 Correct 6 ms 2256 KB Output is correct
28 Correct 6 ms 2128 KB Output is correct
29 Correct 5 ms 2128 KB Output is correct
30 Correct 7 ms 2116 KB Output is correct
31 Correct 6 ms 2128 KB Output is correct
32 Correct 3 ms 1744 KB Output is correct
33 Correct 3 ms 1744 KB Output is correct
34 Correct 3 ms 1872 KB Output is correct
35 Correct 4 ms 2128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 720 KB Output is correct
2 Correct 6 ms 2348 KB Output is correct
3 Correct 6 ms 2256 KB Output is correct
4 Correct 6 ms 2128 KB Output is correct
5 Correct 6 ms 2184 KB Output is correct
6 Correct 6 ms 2172 KB Output is correct
7 Correct 5 ms 2128 KB Output is correct
8 Correct 3 ms 1744 KB Output is correct
9 Correct 3 ms 1744 KB Output is correct
10 Correct 7 ms 2256 KB Output is correct
11 Correct 5 ms 2464 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 3 ms 1712 KB Output is correct
14 Correct 2 ms 1744 KB Output is correct
15 Correct 6 ms 2256 KB Output is correct
16 Correct 5 ms 2128 KB Output is correct
17 Correct 8 ms 2128 KB Output is correct
18 Correct 3 ms 1744 KB Output is correct
19 Correct 4 ms 2004 KB Output is correct
20 Correct 7 ms 2256 KB Output is correct
21 Correct 8 ms 2128 KB Output is correct
22 Correct 6 ms 2128 KB Output is correct
23 Correct 3 ms 1744 KB Output is correct
24 Correct 3 ms 1872 KB Output is correct
25 Correct 3 ms 1104 KB Output is correct
26 Correct 6 ms 2256 KB Output is correct
27 Correct 6 ms 2256 KB Output is correct
28 Correct 6 ms 2128 KB Output is correct
29 Correct 5 ms 2128 KB Output is correct
30 Correct 7 ms 2116 KB Output is correct
31 Correct 6 ms 2128 KB Output is correct
32 Correct 3 ms 1744 KB Output is correct
33 Correct 3 ms 1744 KB Output is correct
34 Correct 3 ms 1872 KB Output is correct
35 Correct 4 ms 2128 KB Output is correct
36 Correct 375 ms 70288 KB Output is correct
37 Correct 596 ms 108608 KB Output is correct
38 Correct 608 ms 108936 KB Output is correct
39 Correct 588 ms 103804 KB Output is correct
40 Correct 602 ms 103692 KB Output is correct
41 Correct 574 ms 103820 KB Output is correct
42 Correct 608 ms 103268 KB Output is correct
43 Correct 137 ms 87228 KB Output is correct
44 Correct 142 ms 87240 KB Output is correct
45 Correct 256 ms 110540 KB Output is correct
46 Correct 228 ms 106956 KB Output is correct
47 Correct 594 ms 108908 KB Output is correct
48 Correct 589 ms 103488 KB Output is correct
49 Correct 529 ms 103140 KB Output is correct
50 Correct 143 ms 87316 KB Output is correct
51 Correct 139 ms 88260 KB Output is correct
52 Correct 620 ms 109284 KB Output is correct
53 Correct 563 ms 103484 KB Output is correct
54 Correct 573 ms 103524 KB Output is correct
55 Correct 147 ms 87472 KB Output is correct
56 Correct 271 ms 114332 KB Output is correct
57 Correct 674 ms 104884 KB Output is correct
58 Correct 628 ms 109440 KB Output is correct
59 Correct 661 ms 108568 KB Output is correct
60 Correct 562 ms 103332 KB Output is correct
61 Correct 594 ms 103460 KB Output is correct
62 Correct 558 ms 103328 KB Output is correct
63 Correct 545 ms 103288 KB Output is correct
64 Correct 168 ms 87312 KB Output is correct
65 Correct 144 ms 87220 KB Output is correct
66 Correct 286 ms 117768 KB Output is correct
67 Correct 151 ms 89804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1662 ms 108444 KB Output is correct
2 Correct 2024 ms 109232 KB Output is correct
3 Correct 2005 ms 108972 KB Output is correct
4 Correct 1834 ms 103772 KB Output is correct
5 Correct 1743 ms 103264 KB Output is correct
6 Correct 1908 ms 103740 KB Output is correct
7 Correct 1931 ms 103756 KB Output is correct
8 Correct 1347 ms 87312 KB Output is correct
9 Correct 1459 ms 87308 KB Output is correct
10 Correct 1385 ms 101376 KB Output is correct
11 Correct 1592 ms 113600 KB Output is correct
12 Correct 1384 ms 87644 KB Output is correct
13 Correct 1180 ms 87348 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 3 ms 1744 KB Output is correct
16 Correct 4 ms 1744 KB Output is correct
17 Correct 611 ms 108940 KB Output is correct
18 Correct 591 ms 103432 KB Output is correct
19 Correct 576 ms 103084 KB Output is correct
20 Correct 146 ms 87280 KB Output is correct
21 Correct 146 ms 88260 KB Output is correct
22 Correct 638 ms 109208 KB Output is correct
23 Correct 545 ms 103472 KB Output is correct
24 Correct 558 ms 103436 KB Output is correct
25 Correct 148 ms 87328 KB Output is correct
26 Correct 293 ms 114392 KB Output is correct
27 Correct 6 ms 2256 KB Output is correct
28 Correct 5 ms 2128 KB Output is correct
29 Correct 5 ms 2132 KB Output is correct
30 Correct 3 ms 1744 KB Output is correct
31 Correct 3 ms 2000 KB Output is correct
32 Correct 6 ms 2256 KB Output is correct
33 Correct 5 ms 2128 KB Output is correct
34 Correct 5 ms 2128 KB Output is correct
35 Correct 3 ms 1744 KB Output is correct
36 Correct 3 ms 1872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 388 ms 25616 KB Output is correct
2 Correct 1461 ms 109052 KB Output is correct
3 Correct 1566 ms 108808 KB Output is correct
4 Correct 1518 ms 103820 KB Output is correct
5 Correct 1536 ms 103424 KB Output is correct
6 Correct 1578 ms 103472 KB Output is correct
7 Correct 1227 ms 103828 KB Output is correct
8 Correct 1033 ms 87224 KB Output is correct
9 Correct 1030 ms 87308 KB Output is correct
10 Correct 1168 ms 116516 KB Output is correct
11 Correct 1174 ms 124372 KB Output is correct
12 Correct 704 ms 109380 KB Output is correct
13 Correct 588 ms 103496 KB Output is correct
14 Correct 558 ms 103416 KB Output is correct
15 Correct 143 ms 87320 KB Output is correct
16 Correct 269 ms 114384 KB Output is correct
17 Correct 587 ms 104672 KB Output is correct
18 Correct 625 ms 109244 KB Output is correct
19 Correct 610 ms 108520 KB Output is correct
20 Correct 575 ms 103320 KB Output is correct
21 Correct 613 ms 103480 KB Output is correct
22 Correct 574 ms 103228 KB Output is correct
23 Correct 543 ms 103408 KB Output is correct
24 Correct 151 ms 87284 KB Output is correct
25 Correct 139 ms 87296 KB Output is correct
26 Correct 294 ms 117788 KB Output is correct
27 Correct 154 ms 89604 KB Output is correct
28 Correct 6 ms 2256 KB Output is correct
29 Correct 5 ms 2128 KB Output is correct
30 Correct 5 ms 2216 KB Output is correct
31 Correct 3 ms 1744 KB Output is correct
32 Correct 3 ms 1872 KB Output is correct
33 Correct 4 ms 1104 KB Output is correct
34 Correct 6 ms 2256 KB Output is correct
35 Correct 6 ms 2256 KB Output is correct
36 Correct 7 ms 2128 KB Output is correct
37 Correct 5 ms 2128 KB Output is correct
38 Correct 6 ms 2128 KB Output is correct
39 Correct 6 ms 2188 KB Output is correct
40 Correct 3 ms 1744 KB Output is correct
41 Correct 4 ms 1744 KB Output is correct
42 Correct 3 ms 1872 KB Output is correct
43 Correct 4 ms 2128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 720 KB Output is correct
2 Correct 6 ms 2348 KB Output is correct
3 Correct 6 ms 2256 KB Output is correct
4 Correct 6 ms 2128 KB Output is correct
5 Correct 6 ms 2184 KB Output is correct
6 Correct 6 ms 2172 KB Output is correct
7 Correct 5 ms 2128 KB Output is correct
8 Correct 3 ms 1744 KB Output is correct
9 Correct 3 ms 1744 KB Output is correct
10 Correct 7 ms 2256 KB Output is correct
11 Correct 5 ms 2464 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 3 ms 1712 KB Output is correct
14 Correct 2 ms 1744 KB Output is correct
15 Correct 6 ms 2256 KB Output is correct
16 Correct 5 ms 2128 KB Output is correct
17 Correct 8 ms 2128 KB Output is correct
18 Correct 3 ms 1744 KB Output is correct
19 Correct 4 ms 2004 KB Output is correct
20 Correct 7 ms 2256 KB Output is correct
21 Correct 8 ms 2128 KB Output is correct
22 Correct 6 ms 2128 KB Output is correct
23 Correct 3 ms 1744 KB Output is correct
24 Correct 3 ms 1872 KB Output is correct
25 Correct 3 ms 1104 KB Output is correct
26 Correct 6 ms 2256 KB Output is correct
27 Correct 6 ms 2256 KB Output is correct
28 Correct 6 ms 2128 KB Output is correct
29 Correct 5 ms 2128 KB Output is correct
30 Correct 7 ms 2116 KB Output is correct
31 Correct 6 ms 2128 KB Output is correct
32 Correct 3 ms 1744 KB Output is correct
33 Correct 3 ms 1744 KB Output is correct
34 Correct 3 ms 1872 KB Output is correct
35 Correct 4 ms 2128 KB Output is correct
36 Correct 375 ms 70288 KB Output is correct
37 Correct 596 ms 108608 KB Output is correct
38 Correct 608 ms 108936 KB Output is correct
39 Correct 588 ms 103804 KB Output is correct
40 Correct 602 ms 103692 KB Output is correct
41 Correct 574 ms 103820 KB Output is correct
42 Correct 608 ms 103268 KB Output is correct
43 Correct 137 ms 87228 KB Output is correct
44 Correct 142 ms 87240 KB Output is correct
45 Correct 256 ms 110540 KB Output is correct
46 Correct 228 ms 106956 KB Output is correct
47 Correct 594 ms 108908 KB Output is correct
48 Correct 589 ms 103488 KB Output is correct
49 Correct 529 ms 103140 KB Output is correct
50 Correct 143 ms 87316 KB Output is correct
51 Correct 139 ms 88260 KB Output is correct
52 Correct 620 ms 109284 KB Output is correct
53 Correct 563 ms 103484 KB Output is correct
54 Correct 573 ms 103524 KB Output is correct
55 Correct 147 ms 87472 KB Output is correct
56 Correct 271 ms 114332 KB Output is correct
57 Correct 674 ms 104884 KB Output is correct
58 Correct 628 ms 109440 KB Output is correct
59 Correct 661 ms 108568 KB Output is correct
60 Correct 562 ms 103332 KB Output is correct
61 Correct 594 ms 103460 KB Output is correct
62 Correct 558 ms 103328 KB Output is correct
63 Correct 545 ms 103288 KB Output is correct
64 Correct 168 ms 87312 KB Output is correct
65 Correct 144 ms 87220 KB Output is correct
66 Correct 286 ms 117768 KB Output is correct
67 Correct 151 ms 89804 KB Output is correct
68 Correct 1662 ms 108444 KB Output is correct
69 Correct 2024 ms 109232 KB Output is correct
70 Correct 2005 ms 108972 KB Output is correct
71 Correct 1834 ms 103772 KB Output is correct
72 Correct 1743 ms 103264 KB Output is correct
73 Correct 1908 ms 103740 KB Output is correct
74 Correct 1931 ms 103756 KB Output is correct
75 Correct 1347 ms 87312 KB Output is correct
76 Correct 1459 ms 87308 KB Output is correct
77 Correct 1385 ms 101376 KB Output is correct
78 Correct 1592 ms 113600 KB Output is correct
79 Correct 1384 ms 87644 KB Output is correct
80 Correct 1180 ms 87348 KB Output is correct
81 Correct 0 ms 208 KB Output is correct
82 Correct 3 ms 1744 KB Output is correct
83 Correct 4 ms 1744 KB Output is correct
84 Correct 611 ms 108940 KB Output is correct
85 Correct 591 ms 103432 KB Output is correct
86 Correct 576 ms 103084 KB Output is correct
87 Correct 146 ms 87280 KB Output is correct
88 Correct 146 ms 88260 KB Output is correct
89 Correct 638 ms 109208 KB Output is correct
90 Correct 545 ms 103472 KB Output is correct
91 Correct 558 ms 103436 KB Output is correct
92 Correct 148 ms 87328 KB Output is correct
93 Correct 293 ms 114392 KB Output is correct
94 Correct 6 ms 2256 KB Output is correct
95 Correct 5 ms 2128 KB Output is correct
96 Correct 5 ms 2132 KB Output is correct
97 Correct 3 ms 1744 KB Output is correct
98 Correct 3 ms 2000 KB Output is correct
99 Correct 6 ms 2256 KB Output is correct
100 Correct 5 ms 2128 KB Output is correct
101 Correct 5 ms 2128 KB Output is correct
102 Correct 3 ms 1744 KB Output is correct
103 Correct 3 ms 1872 KB Output is correct
104 Correct 1674 ms 96408 KB Output is correct
105 Correct 2040 ms 108928 KB Output is correct
106 Correct 2028 ms 109024 KB Output is correct
107 Correct 1858 ms 103552 KB Output is correct
108 Correct 2049 ms 103480 KB Output is correct
109 Correct 1971 ms 103336 KB Output is correct
110 Correct 1801 ms 103896 KB Output is correct
111 Correct 1289 ms 87220 KB Output is correct
112 Correct 1220 ms 87336 KB Output is correct
113 Correct 1483 ms 125324 KB Output is correct
114 Correct 1531 ms 112876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 682 ms 49796 KB Output is correct
2 Correct 1351 ms 87500 KB Output is correct
3 Correct 1400 ms 87544 KB Output is correct
4 Correct 1133 ms 87364 KB Output is correct
5 Correct 1250 ms 87376 KB Output is correct
6 Correct 1342 ms 87308 KB Output is correct
7 Correct 1308 ms 87316 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 3 ms 1728 KB Output is correct
10 Correct 3 ms 1744 KB Output is correct
11 Correct 1 ms 720 KB Output is correct
12 Correct 6 ms 2348 KB Output is correct
13 Correct 6 ms 2256 KB Output is correct
14 Correct 6 ms 2128 KB Output is correct
15 Correct 6 ms 2184 KB Output is correct
16 Correct 6 ms 2172 KB Output is correct
17 Correct 5 ms 2128 KB Output is correct
18 Correct 3 ms 1744 KB Output is correct
19 Correct 3 ms 1744 KB Output is correct
20 Correct 7 ms 2256 KB Output is correct
21 Correct 5 ms 2464 KB Output is correct
22 Correct 0 ms 208 KB Output is correct
23 Correct 3 ms 1712 KB Output is correct
24 Correct 2 ms 1744 KB Output is correct
25 Correct 6 ms 2256 KB Output is correct
26 Correct 5 ms 2128 KB Output is correct
27 Correct 8 ms 2128 KB Output is correct
28 Correct 3 ms 1744 KB Output is correct
29 Correct 4 ms 2004 KB Output is correct
30 Correct 7 ms 2256 KB Output is correct
31 Correct 8 ms 2128 KB Output is correct
32 Correct 6 ms 2128 KB Output is correct
33 Correct 3 ms 1744 KB Output is correct
34 Correct 3 ms 1872 KB Output is correct
35 Correct 3 ms 1104 KB Output is correct
36 Correct 6 ms 2256 KB Output is correct
37 Correct 6 ms 2256 KB Output is correct
38 Correct 6 ms 2128 KB Output is correct
39 Correct 5 ms 2128 KB Output is correct
40 Correct 7 ms 2116 KB Output is correct
41 Correct 6 ms 2128 KB Output is correct
42 Correct 3 ms 1744 KB Output is correct
43 Correct 3 ms 1744 KB Output is correct
44 Correct 3 ms 1872 KB Output is correct
45 Correct 4 ms 2128 KB Output is correct
46 Correct 375 ms 70288 KB Output is correct
47 Correct 596 ms 108608 KB Output is correct
48 Correct 608 ms 108936 KB Output is correct
49 Correct 588 ms 103804 KB Output is correct
50 Correct 602 ms 103692 KB Output is correct
51 Correct 574 ms 103820 KB Output is correct
52 Correct 608 ms 103268 KB Output is correct
53 Correct 137 ms 87228 KB Output is correct
54 Correct 142 ms 87240 KB Output is correct
55 Correct 256 ms 110540 KB Output is correct
56 Correct 228 ms 106956 KB Output is correct
57 Correct 594 ms 108908 KB Output is correct
58 Correct 589 ms 103488 KB Output is correct
59 Correct 529 ms 103140 KB Output is correct
60 Correct 143 ms 87316 KB Output is correct
61 Correct 139 ms 88260 KB Output is correct
62 Correct 620 ms 109284 KB Output is correct
63 Correct 563 ms 103484 KB Output is correct
64 Correct 573 ms 103524 KB Output is correct
65 Correct 147 ms 87472 KB Output is correct
66 Correct 271 ms 114332 KB Output is correct
67 Correct 674 ms 104884 KB Output is correct
68 Correct 628 ms 109440 KB Output is correct
69 Correct 661 ms 108568 KB Output is correct
70 Correct 562 ms 103332 KB Output is correct
71 Correct 594 ms 103460 KB Output is correct
72 Correct 558 ms 103328 KB Output is correct
73 Correct 545 ms 103288 KB Output is correct
74 Correct 168 ms 87312 KB Output is correct
75 Correct 144 ms 87220 KB Output is correct
76 Correct 286 ms 117768 KB Output is correct
77 Correct 151 ms 89804 KB Output is correct
78 Correct 1662 ms 108444 KB Output is correct
79 Correct 2024 ms 109232 KB Output is correct
80 Correct 2005 ms 108972 KB Output is correct
81 Correct 1834 ms 103772 KB Output is correct
82 Correct 1743 ms 103264 KB Output is correct
83 Correct 1908 ms 103740 KB Output is correct
84 Correct 1931 ms 103756 KB Output is correct
85 Correct 1347 ms 87312 KB Output is correct
86 Correct 1459 ms 87308 KB Output is correct
87 Correct 1385 ms 101376 KB Output is correct
88 Correct 1592 ms 113600 KB Output is correct
89 Correct 1384 ms 87644 KB Output is correct
90 Correct 1180 ms 87348 KB Output is correct
91 Correct 0 ms 208 KB Output is correct
92 Correct 3 ms 1744 KB Output is correct
93 Correct 4 ms 1744 KB Output is correct
94 Correct 611 ms 108940 KB Output is correct
95 Correct 591 ms 103432 KB Output is correct
96 Correct 576 ms 103084 KB Output is correct
97 Correct 146 ms 87280 KB Output is correct
98 Correct 146 ms 88260 KB Output is correct
99 Correct 638 ms 109208 KB Output is correct
100 Correct 545 ms 103472 KB Output is correct
101 Correct 558 ms 103436 KB Output is correct
102 Correct 148 ms 87328 KB Output is correct
103 Correct 293 ms 114392 KB Output is correct
104 Correct 6 ms 2256 KB Output is correct
105 Correct 5 ms 2128 KB Output is correct
106 Correct 5 ms 2132 KB Output is correct
107 Correct 3 ms 1744 KB Output is correct
108 Correct 3 ms 2000 KB Output is correct
109 Correct 6 ms 2256 KB Output is correct
110 Correct 5 ms 2128 KB Output is correct
111 Correct 5 ms 2128 KB Output is correct
112 Correct 3 ms 1744 KB Output is correct
113 Correct 3 ms 1872 KB Output is correct
114 Correct 388 ms 25616 KB Output is correct
115 Correct 1461 ms 109052 KB Output is correct
116 Correct 1566 ms 108808 KB Output is correct
117 Correct 1518 ms 103820 KB Output is correct
118 Correct 1536 ms 103424 KB Output is correct
119 Correct 1578 ms 103472 KB Output is correct
120 Correct 1227 ms 103828 KB Output is correct
121 Correct 1033 ms 87224 KB Output is correct
122 Correct 1030 ms 87308 KB Output is correct
123 Correct 1168 ms 116516 KB Output is correct
124 Correct 1174 ms 124372 KB Output is correct
125 Correct 704 ms 109380 KB Output is correct
126 Correct 588 ms 103496 KB Output is correct
127 Correct 558 ms 103416 KB Output is correct
128 Correct 143 ms 87320 KB Output is correct
129 Correct 269 ms 114384 KB Output is correct
130 Correct 587 ms 104672 KB Output is correct
131 Correct 625 ms 109244 KB Output is correct
132 Correct 610 ms 108520 KB Output is correct
133 Correct 575 ms 103320 KB Output is correct
134 Correct 613 ms 103480 KB Output is correct
135 Correct 574 ms 103228 KB Output is correct
136 Correct 543 ms 103408 KB Output is correct
137 Correct 151 ms 87284 KB Output is correct
138 Correct 139 ms 87296 KB Output is correct
139 Correct 294 ms 117788 KB Output is correct
140 Correct 154 ms 89604 KB Output is correct
141 Correct 6 ms 2256 KB Output is correct
142 Correct 5 ms 2128 KB Output is correct
143 Correct 5 ms 2216 KB Output is correct
144 Correct 3 ms 1744 KB Output is correct
145 Correct 3 ms 1872 KB Output is correct
146 Correct 4 ms 1104 KB Output is correct
147 Correct 6 ms 2256 KB Output is correct
148 Correct 6 ms 2256 KB Output is correct
149 Correct 7 ms 2128 KB Output is correct
150 Correct 5 ms 2128 KB Output is correct
151 Correct 6 ms 2128 KB Output is correct
152 Correct 6 ms 2188 KB Output is correct
153 Correct 3 ms 1744 KB Output is correct
154 Correct 4 ms 1744 KB Output is correct
155 Correct 3 ms 1872 KB Output is correct
156 Correct 4 ms 2128 KB Output is correct
157 Correct 1674 ms 96408 KB Output is correct
158 Correct 2040 ms 108928 KB Output is correct
159 Correct 2028 ms 109024 KB Output is correct
160 Correct 1858 ms 103552 KB Output is correct
161 Correct 2049 ms 103480 KB Output is correct
162 Correct 1971 ms 103336 KB Output is correct
163 Correct 1801 ms 103896 KB Output is correct
164 Correct 1289 ms 87220 KB Output is correct
165 Correct 1220 ms 87336 KB Output is correct
166 Correct 1483 ms 125324 KB Output is correct
167 Correct 1531 ms 112876 KB Output is correct
168 Correct 0 ms 208 KB Output is correct
169 Correct 1132 ms 37600 KB Output is correct
170 Correct 2168 ms 108936 KB Output is correct
171 Correct 2078 ms 109032 KB Output is correct
172 Correct 2061 ms 104052 KB Output is correct
173 Correct 2112 ms 103368 KB Output is correct
174 Correct 2190 ms 103540 KB Output is correct
175 Correct 1988 ms 103620 KB Output is correct
176 Correct 1255 ms 87304 KB Output is correct
177 Correct 1403 ms 87316 KB Output is correct
178 Correct 1659 ms 127964 KB Output is correct
179 Correct 1619 ms 111480 KB Output is correct