Submission #968978

# Submission time Handle Problem Language Result Execution time Memory
968978 2024-04-24T10:39:38 Z maksim1744 Radio Towers (IOI22_towers) C++17
100 / 100
1281 ms 322400 KB
/*
    author:  Maksim1744
    created: 24.04.2024 03:13:57
*/

#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

#define mp   make_pair
#define pb   push_back
#define eb   emplace_back

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

template<typename T>             vector<T>& operator--            (vector<T> &v){for (auto& i : v) --i;            return  v;}
template<typename T>             vector<T>& operator++            (vector<T> &v){for (auto& i : v) ++i;            return  v;}
template<typename T>             istream& operator>>(istream& is,  vector<T> &v){for (auto& i : v) is >> i;        return is;}
template<typename T>             ostream& operator<<(ostream& os,  vector<T>  v){for (auto& i : v) os << i << ' '; return os;}
template<typename T, typename U> pair<T,U>& operator--           (pair<T, U> &p){--p.first; --p.second;            return  p;}
template<typename T, typename U> pair<T,U>& operator++           (pair<T, U> &p){++p.first; ++p.second;            return  p;}
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U> &p){is >> p.first >> p.second;        return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, pair<T, U>  p){os << p.first << ' ' << p.second; return os;}
template<typename T, typename U> pair<T,U> operator-(pair<T,U> a, pair<T,U> b){return mp(a.first-b.first, a.second-b.second);}
template<typename T, typename U> pair<T,U> operator+(pair<T,U> a, pair<T,U> b){return mp(a.first+b.first, a.second+b.second);}
template<typename T, typename U> void umin(T& a, U b){if (a > b) a = b;}
template<typename T, typename U> void umax(T& a, U b){if (a < b) a = b;}

#ifdef HOME
#define SHOW_COLORS
#include "/mnt/c/Libs/tools/print.cpp"
#else
#define show(...) void(0)
#define debugf(fun)   fun
#define debugv(var)   var
#define mclock    void(0)
#define shows     void(0)
#define debug  if (false)
#define OSTREAM(...)    ;
#define OSTREAM0(...)   ;
#endif

template<typename T, typename F = std::function<T(const T&, const T&)>>
struct SparseTable {
    vector<vector<T>> table;
    vector<int> p2;
    F combine;

    SparseTable(int n, F combine) : combine(combine) {
        while ((1 << table.size()) <= n || table.empty())
            table.emplace_back(n);
    }
    template<typename U>
    SparseTable(const vector<U>& v, F combine) : SparseTable<T>(v.size(), combine) {
        table[0].assign(v.begin(), v.end());
        build();
    }

    void build() {
        p2.resize(table[0].size() + 1);
        for (int i = 2; i < p2.size(); ++i)
            p2[i] = p2[i / 2] + 1;
        for (int i = 1; i < table.size(); ++i) {
            for (int j = 0; j + (1 << i) <= table[i].size(); ++j) {
                table[i][j] = combine(table[i - 1][j], table[i - 1][j + (1 << (i - 1))]);
            }
        }
    }

    T ask(int l, int r) {
        int ln = p2[r - l + 1];
        if (r - l + 1 == ln) return table[ln][l];
        return combine(table[ln][l], table[ln][r - (1 << ln) + 1]);
    }
};

const int inf = 2e9;

int n;
vector<int> h;
SparseTable<int> sparse_min(1, [](int a, int b) { return min(a, b); });
SparseTable<int> sparse_max(1, [](int a, int b) { return max(a, b); });
vector<int> hill, valley;

struct Node {
    Node* l = nullptr;
    Node* r = nullptr;

    int len = 0;
    int left = -1;
    int last_new = -1;

    Node() {}
    Node(int x, int ind) {
        left = x;
        len = 0;
        if (left != -1) {
            last_new = ind;
            len = 1;
        }
    }

    int right() const {
        return len % 2 == 1 ? left : 1 - left;
    }

    void update() {
        assert(l != nullptr);
        assert(r != nullptr);
        if (l->len == 0) {
            len = r->len;
            left = r->left;
            last_new = r->last_new;
        } else if (r->len == 0) {
            len = l->len;
            left = l->left;
            last_new = l->last_new;
        } else {
            len = l->len + r->len - (l->right() == r->left);
            if (r->len == 1 && r->left == l->right()) {
                last_new = l->last_new;
            } else {
                last_new = r->last_new;
            }
            left = l->left;
            assert(right() == r->right());
        }
    }
};

OSTREAM(Node, len, left, last_new);

Node* build(int l, int r, const vector<int>& v) {
    if (l == r) {
        return new Node(v[l], l);
    }
    int m = (l + r) / 2;
    auto node = new Node();
    node->l = build(l, m, v);
    node->r = build(m + 1, r, v);
    node->update();
    return node;
}

Node* update(Node* node, int i, int val, int vl, int vr) {
    if (vl == vr) {
        return new Node(val, i);
    }
    auto root = new Node();
    root->l = node->l;
    root->r = node->r;
    int m = (vl + vr) / 2;
    if (i <= m) {
        root->l = update(node->l, i, val, vl, m);
    } else {
        root->r = update(node->r, i, val, m + 1, vr);
    }
    root->update();
    return root;
}

Node* ask(Node* node, int l, int r, int vl, int vr) {
    if (l <= vl && vr <= r) {
        return node;
    }
    if (vr < l || vl > r) {
        return new Node(-1, -1);
    }
    int m = (vl + vr) / 2;
    Node* n = new Node();
    n->l = ask(node->l, l, r, vl, m);
    n->r = ask(node->r, l, r, m + 1, vr);

    n->update();
    return n;
}

vector<Node*> roots;
vector<int> ds;

void init(int n_, std::vector<int> h_) {
    n = n_;
    h = h_;
    h.pb(inf);
    n = h.size();
    roots.clear();
    ds.clear();

    sparse_min = SparseTable<int>(h, [](int a, int b) { return min(a, b); });
    sparse_max = SparseTable<int>(h, [](int a, int b) { return max(a, b); });
    hill.assign(n, -1);
    valley.assign(n, -1);
    vector<int> stup, stdown;
    for (int i = n - 1; i >= 0; --i) {
        while (!stup.empty() && h[stup.back()] < h[i])
            stup.pop_back();
        while (!stdown.empty() && h[stdown.back()] > h[i])
            stdown.pop_back();
        if (stup.empty()) {
            hill[i] = inf;
        } else {
            hill[i] = h[i] - sparse_min.ask(i, stup.back());
        }
        if (stdown.empty()) {
            valley[i] = inf;
        } else {
            valley[i] = -h[i] + sparse_max.ask(i, stdown.back());
        }

        stup.push_back(i);
        stdown.push_back(i);
    }

    vector<pair<int, int>> events;
    for (int i = 0; i < n; ++i) {
        if (hill[i] > 0) events.eb(hill[i], i);
        if (valley[i] > 0) events.eb(valley[i], i);
    }
    show(hill);
    show(valley);
    show(events);

    sort(events.begin(), events.end());
    reverse(events.begin(), events.end());

    ds.pb(inf + 1);
    roots.pb(build(0, n-1, vector<int>(n, -1)));

    int ind = 0;
    while (ind < events.size()) {
        shows;
        int r = ind;
        Node* next = roots.back();
        ds.pb(events[ind].first);
        show(ds.back());
        while (r < events.size() && events[r].first == events[ind].first) {
            int i = events[r].second;
            int val = (ds.back() <= hill[i] ? 1 : (ds.back() <= valley[i] ? 0 : -1));
            show(i, val);
            next = update(next, i, val, 0, n-1);
            ++r;
        }
        roots.pb(next);

        ind = r;
    }
}

int max_towers(int l, int r, int d) {
    if (l == r) return 1;
    // show(hill);
    // show(valley);
    // int dir = -1;
    // int ans = 0;
    // int last = -1;
    // for (int i = l; i < r; ++i) {
    //     if (d <= (dir == 1 ? hill[i] : valley[i])) {
    //         ++ans;
    //         last = i;
    //         dir = -dir;
    //     }
    // }

    // if (ans % 2 == 0 && ans > 0 && sparse_min.ask(last + 1, r) <= h[last] - d)
    //     ++ans;
    // return max(1, (ans + 1) / 2);

    int L = -1, R = ds.size();
    while (R - L > 1) {
        int C = (L + R) / 2;
        if (ds[C] >= d)
            L = C;
        else
            R = C;
    }
    show(ds);
    show(L);
    auto res = ask(roots[L], l, r-1, 0, n-1);
    show(*roots[L]);
    show(*res);
    int ans = 0;
    if (res->len > 0) {
        ans = res->len;
        if (res->left == 1) {
            --ans;
        }
        int last = res->last_new;
        if (ans % 2 == 0 && ans > 0 && sparse_min.ask(last + 1, r) <= h[last] - d)
            ++ans;
    }
    return max(1, (ans + 1) / 2);
}


#ifdef HOUSE

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    int n, q;
    cin >> n >> q;
    vector<int> h(n);
    cin >> h;
    init(n, h);
    while (q--) {
        int l, r, d;
        cin >> l >> r >> d;
        cout << max_towers(l, r, d) << '\n';
    }

    return 0;
}
#endif

Compilation message

towers.cpp: In function 'void init(int, std::vector<int>)':
towers.cpp:239:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  239 |     while (ind < events.size()) {
      |            ~~~~^~~~~~~~~~~~~~~
towers.cpp:245:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  245 |         while (r < events.size() && events[r].first == events[ind].first) {
      |                ~~^~~~~~~~~~~~~~~
towers.cpp: In instantiation of 'void SparseTable<T, F>::build() [with T = int; F = std::function<int(const int&, const int&)>]':
towers.cpp:65:9:   required from 'SparseTable<T, F>::SparseTable(const std::vector<U>&, F) [with U = int; T = int; F = std::function<int(const int&, const int&)>]'
towers.cpp:198:76:   required from here
towers.cpp:70:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |         for (int i = 2; i < p2.size(); ++i)
      |                         ~~^~~~~~~~~~~
towers.cpp:72:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int>, std::allocator<std::vector<int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |         for (int i = 1; i < table.size(); ++i) {
      |                         ~~^~~~~~~~~~~~~~
towers.cpp:73:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |             for (int j = 0; j + (1 << i) <= table[i].size(); ++j) {
      |                             ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 479 ms 158132 KB Output is correct
2 Correct 1058 ms 322280 KB Output is correct
3 Correct 1025 ms 322400 KB Output is correct
4 Correct 951 ms 320908 KB Output is correct
5 Correct 1087 ms 322244 KB Output is correct
6 Correct 943 ms 322076 KB Output is correct
7 Correct 965 ms 321980 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 2 ms 1880 KB Output is correct
10 Correct 2 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 2 ms 1880 KB Output is correct
3 Correct 2 ms 1880 KB Output is correct
4 Correct 2 ms 1880 KB Output is correct
5 Correct 2 ms 1880 KB Output is correct
6 Correct 2 ms 1880 KB Output is correct
7 Correct 2 ms 1880 KB Output is correct
8 Correct 2 ms 2036 KB Output is correct
9 Correct 2 ms 1880 KB Output is correct
10 Correct 2 ms 1880 KB Output is correct
11 Correct 2 ms 1880 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 2 ms 1880 KB Output is correct
14 Correct 2 ms 1880 KB Output is correct
15 Correct 2 ms 1880 KB Output is correct
16 Correct 2 ms 1880 KB Output is correct
17 Correct 2 ms 1880 KB Output is correct
18 Correct 2 ms 1880 KB Output is correct
19 Correct 2 ms 1880 KB Output is correct
20 Correct 2 ms 1880 KB Output is correct
21 Correct 2 ms 1880 KB Output is correct
22 Correct 2 ms 1880 KB Output is correct
23 Correct 2 ms 1880 KB Output is correct
24 Correct 2 ms 1880 KB Output is correct
25 Correct 1 ms 856 KB Output is correct
26 Correct 2 ms 1880 KB Output is correct
27 Correct 2 ms 1880 KB Output is correct
28 Correct 2 ms 1880 KB Output is correct
29 Correct 2 ms 2132 KB Output is correct
30 Correct 2 ms 1880 KB Output is correct
31 Correct 3 ms 1880 KB Output is correct
32 Correct 2 ms 1880 KB Output is correct
33 Correct 2 ms 1880 KB Output is correct
34 Correct 2 ms 1880 KB Output is correct
35 Correct 2 ms 1880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 2 ms 1880 KB Output is correct
3 Correct 2 ms 1880 KB Output is correct
4 Correct 2 ms 1880 KB Output is correct
5 Correct 2 ms 1880 KB Output is correct
6 Correct 2 ms 1880 KB Output is correct
7 Correct 2 ms 1880 KB Output is correct
8 Correct 2 ms 2036 KB Output is correct
9 Correct 2 ms 1880 KB Output is correct
10 Correct 2 ms 1880 KB Output is correct
11 Correct 2 ms 1880 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 2 ms 1880 KB Output is correct
14 Correct 2 ms 1880 KB Output is correct
15 Correct 2 ms 1880 KB Output is correct
16 Correct 2 ms 1880 KB Output is correct
17 Correct 2 ms 1880 KB Output is correct
18 Correct 2 ms 1880 KB Output is correct
19 Correct 2 ms 1880 KB Output is correct
20 Correct 2 ms 1880 KB Output is correct
21 Correct 2 ms 1880 KB Output is correct
22 Correct 2 ms 1880 KB Output is correct
23 Correct 2 ms 1880 KB Output is correct
24 Correct 2 ms 1880 KB Output is correct
25 Correct 1 ms 856 KB Output is correct
26 Correct 2 ms 1880 KB Output is correct
27 Correct 2 ms 1880 KB Output is correct
28 Correct 2 ms 1880 KB Output is correct
29 Correct 2 ms 2132 KB Output is correct
30 Correct 2 ms 1880 KB Output is correct
31 Correct 3 ms 1880 KB Output is correct
32 Correct 2 ms 1880 KB Output is correct
33 Correct 2 ms 1880 KB Output is correct
34 Correct 2 ms 1880 KB Output is correct
35 Correct 2 ms 1880 KB Output is correct
36 Correct 92 ms 69560 KB Output is correct
37 Correct 155 ms 110676 KB Output is correct
38 Correct 157 ms 111016 KB Output is correct
39 Correct 153 ms 110760 KB Output is correct
40 Correct 160 ms 110708 KB Output is correct
41 Correct 157 ms 110744 KB Output is correct
42 Correct 157 ms 110748 KB Output is correct
43 Correct 111 ms 109976 KB Output is correct
44 Correct 112 ms 111116 KB Output is correct
45 Correct 108 ms 110480 KB Output is correct
46 Correct 111 ms 110956 KB Output is correct
47 Correct 160 ms 110764 KB Output is correct
48 Correct 157 ms 110752 KB Output is correct
49 Correct 166 ms 111072 KB Output is correct
50 Correct 112 ms 111256 KB Output is correct
51 Correct 110 ms 110000 KB Output is correct
52 Correct 167 ms 110764 KB Output is correct
53 Correct 156 ms 110768 KB Output is correct
54 Correct 166 ms 110764 KB Output is correct
55 Correct 113 ms 111300 KB Output is correct
56 Correct 108 ms 110800 KB Output is correct
57 Correct 150 ms 106920 KB Output is correct
58 Correct 155 ms 111000 KB Output is correct
59 Correct 159 ms 110884 KB Output is correct
60 Correct 192 ms 110704 KB Output is correct
61 Correct 152 ms 110920 KB Output is correct
62 Correct 166 ms 110700 KB Output is correct
63 Correct 154 ms 110760 KB Output is correct
64 Correct 106 ms 109976 KB Output is correct
65 Correct 115 ms 111276 KB Output is correct
66 Correct 111 ms 110752 KB Output is correct
67 Correct 110 ms 111276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 847 ms 271420 KB Output is correct
2 Correct 997 ms 321800 KB Output is correct
3 Correct 1046 ms 321800 KB Output is correct
4 Correct 1048 ms 322052 KB Output is correct
5 Correct 1010 ms 322264 KB Output is correct
6 Correct 1006 ms 321940 KB Output is correct
7 Correct 1006 ms 322396 KB Output is correct
8 Correct 961 ms 320444 KB Output is correct
9 Correct 1018 ms 322224 KB Output is correct
10 Correct 963 ms 321344 KB Output is correct
11 Correct 1065 ms 322016 KB Output is correct
12 Correct 970 ms 321608 KB Output is correct
13 Correct 981 ms 322212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 1880 KB Output is correct
16 Correct 2 ms 1880 KB Output is correct
17 Correct 168 ms 110812 KB Output is correct
18 Correct 160 ms 110928 KB Output is correct
19 Correct 164 ms 110900 KB Output is correct
20 Correct 118 ms 111268 KB Output is correct
21 Correct 117 ms 110108 KB Output is correct
22 Correct 163 ms 110796 KB Output is correct
23 Correct 163 ms 110756 KB Output is correct
24 Correct 176 ms 110720 KB Output is correct
25 Correct 113 ms 111260 KB Output is correct
26 Correct 109 ms 110596 KB Output is correct
27 Correct 2 ms 1880 KB Output is correct
28 Correct 3 ms 1964 KB Output is correct
29 Correct 2 ms 1880 KB Output is correct
30 Correct 2 ms 1876 KB Output is correct
31 Correct 2 ms 1880 KB Output is correct
32 Correct 2 ms 1880 KB Output is correct
33 Correct 2 ms 2012 KB Output is correct
34 Correct 2 ms 1880 KB Output is correct
35 Correct 2 ms 1880 KB Output is correct
36 Correct 2 ms 1880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 242 ms 44828 KB Output is correct
2 Correct 948 ms 199708 KB Output is correct
3 Correct 937 ms 199460 KB Output is correct
4 Correct 887 ms 199288 KB Output is correct
5 Correct 921 ms 199472 KB Output is correct
6 Correct 899 ms 199300 KB Output is correct
7 Correct 873 ms 199676 KB Output is correct
8 Correct 776 ms 198644 KB Output is correct
9 Correct 815 ms 199920 KB Output is correct
10 Correct 782 ms 198976 KB Output is correct
11 Correct 808 ms 199736 KB Output is correct
12 Correct 193 ms 110836 KB Output is correct
13 Correct 215 ms 110712 KB Output is correct
14 Correct 159 ms 110760 KB Output is correct
15 Correct 112 ms 111228 KB Output is correct
16 Correct 112 ms 110572 KB Output is correct
17 Correct 164 ms 106960 KB Output is correct
18 Correct 159 ms 110956 KB Output is correct
19 Correct 165 ms 110904 KB Output is correct
20 Correct 155 ms 110784 KB Output is correct
21 Correct 157 ms 110776 KB Output is correct
22 Correct 184 ms 110752 KB Output is correct
23 Correct 158 ms 110744 KB Output is correct
24 Correct 116 ms 109984 KB Output is correct
25 Correct 116 ms 111096 KB Output is correct
26 Correct 116 ms 111024 KB Output is correct
27 Correct 112 ms 111260 KB Output is correct
28 Correct 3 ms 1880 KB Output is correct
29 Correct 2 ms 1960 KB Output is correct
30 Correct 2 ms 1880 KB Output is correct
31 Correct 2 ms 1880 KB Output is correct
32 Correct 2 ms 2136 KB Output is correct
33 Correct 1 ms 856 KB Output is correct
34 Correct 2 ms 1880 KB Output is correct
35 Correct 2 ms 1880 KB Output is correct
36 Correct 2 ms 1880 KB Output is correct
37 Correct 2 ms 1968 KB Output is correct
38 Correct 2 ms 1880 KB Output is correct
39 Correct 2 ms 2132 KB Output is correct
40 Correct 2 ms 1880 KB Output is correct
41 Correct 2 ms 1880 KB Output is correct
42 Correct 2 ms 1880 KB Output is correct
43 Correct 2 ms 1880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 2 ms 1880 KB Output is correct
3 Correct 2 ms 1880 KB Output is correct
4 Correct 2 ms 1880 KB Output is correct
5 Correct 2 ms 1880 KB Output is correct
6 Correct 2 ms 1880 KB Output is correct
7 Correct 2 ms 1880 KB Output is correct
8 Correct 2 ms 2036 KB Output is correct
9 Correct 2 ms 1880 KB Output is correct
10 Correct 2 ms 1880 KB Output is correct
11 Correct 2 ms 1880 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 2 ms 1880 KB Output is correct
14 Correct 2 ms 1880 KB Output is correct
15 Correct 2 ms 1880 KB Output is correct
16 Correct 2 ms 1880 KB Output is correct
17 Correct 2 ms 1880 KB Output is correct
18 Correct 2 ms 1880 KB Output is correct
19 Correct 2 ms 1880 KB Output is correct
20 Correct 2 ms 1880 KB Output is correct
21 Correct 2 ms 1880 KB Output is correct
22 Correct 2 ms 1880 KB Output is correct
23 Correct 2 ms 1880 KB Output is correct
24 Correct 2 ms 1880 KB Output is correct
25 Correct 1 ms 856 KB Output is correct
26 Correct 2 ms 1880 KB Output is correct
27 Correct 2 ms 1880 KB Output is correct
28 Correct 2 ms 1880 KB Output is correct
29 Correct 2 ms 2132 KB Output is correct
30 Correct 2 ms 1880 KB Output is correct
31 Correct 3 ms 1880 KB Output is correct
32 Correct 2 ms 1880 KB Output is correct
33 Correct 2 ms 1880 KB Output is correct
34 Correct 2 ms 1880 KB Output is correct
35 Correct 2 ms 1880 KB Output is correct
36 Correct 92 ms 69560 KB Output is correct
37 Correct 155 ms 110676 KB Output is correct
38 Correct 157 ms 111016 KB Output is correct
39 Correct 153 ms 110760 KB Output is correct
40 Correct 160 ms 110708 KB Output is correct
41 Correct 157 ms 110744 KB Output is correct
42 Correct 157 ms 110748 KB Output is correct
43 Correct 111 ms 109976 KB Output is correct
44 Correct 112 ms 111116 KB Output is correct
45 Correct 108 ms 110480 KB Output is correct
46 Correct 111 ms 110956 KB Output is correct
47 Correct 160 ms 110764 KB Output is correct
48 Correct 157 ms 110752 KB Output is correct
49 Correct 166 ms 111072 KB Output is correct
50 Correct 112 ms 111256 KB Output is correct
51 Correct 110 ms 110000 KB Output is correct
52 Correct 167 ms 110764 KB Output is correct
53 Correct 156 ms 110768 KB Output is correct
54 Correct 166 ms 110764 KB Output is correct
55 Correct 113 ms 111300 KB Output is correct
56 Correct 108 ms 110800 KB Output is correct
57 Correct 150 ms 106920 KB Output is correct
58 Correct 155 ms 111000 KB Output is correct
59 Correct 159 ms 110884 KB Output is correct
60 Correct 192 ms 110704 KB Output is correct
61 Correct 152 ms 110920 KB Output is correct
62 Correct 166 ms 110700 KB Output is correct
63 Correct 154 ms 110760 KB Output is correct
64 Correct 106 ms 109976 KB Output is correct
65 Correct 115 ms 111276 KB Output is correct
66 Correct 111 ms 110752 KB Output is correct
67 Correct 110 ms 111276 KB Output is correct
68 Correct 847 ms 271420 KB Output is correct
69 Correct 997 ms 321800 KB Output is correct
70 Correct 1046 ms 321800 KB Output is correct
71 Correct 1048 ms 322052 KB Output is correct
72 Correct 1010 ms 322264 KB Output is correct
73 Correct 1006 ms 321940 KB Output is correct
74 Correct 1006 ms 322396 KB Output is correct
75 Correct 961 ms 320444 KB Output is correct
76 Correct 1018 ms 322224 KB Output is correct
77 Correct 963 ms 321344 KB Output is correct
78 Correct 1065 ms 322016 KB Output is correct
79 Correct 970 ms 321608 KB Output is correct
80 Correct 981 ms 322212 KB Output is correct
81 Correct 1 ms 340 KB Output is correct
82 Correct 2 ms 1880 KB Output is correct
83 Correct 2 ms 1880 KB Output is correct
84 Correct 168 ms 110812 KB Output is correct
85 Correct 160 ms 110928 KB Output is correct
86 Correct 164 ms 110900 KB Output is correct
87 Correct 118 ms 111268 KB Output is correct
88 Correct 117 ms 110108 KB Output is correct
89 Correct 163 ms 110796 KB Output is correct
90 Correct 163 ms 110756 KB Output is correct
91 Correct 176 ms 110720 KB Output is correct
92 Correct 113 ms 111260 KB Output is correct
93 Correct 109 ms 110596 KB Output is correct
94 Correct 2 ms 1880 KB Output is correct
95 Correct 3 ms 1964 KB Output is correct
96 Correct 2 ms 1880 KB Output is correct
97 Correct 2 ms 1876 KB Output is correct
98 Correct 2 ms 1880 KB Output is correct
99 Correct 2 ms 1880 KB Output is correct
100 Correct 2 ms 2012 KB Output is correct
101 Correct 2 ms 1880 KB Output is correct
102 Correct 2 ms 1880 KB Output is correct
103 Correct 2 ms 1880 KB Output is correct
104 Correct 875 ms 276712 KB Output is correct
105 Correct 1055 ms 321828 KB Output is correct
106 Correct 992 ms 321924 KB Output is correct
107 Correct 1057 ms 322148 KB Output is correct
108 Correct 1033 ms 322188 KB Output is correct
109 Correct 1029 ms 322308 KB Output is correct
110 Correct 1100 ms 322092 KB Output is correct
111 Correct 957 ms 321304 KB Output is correct
112 Correct 960 ms 322068 KB Output is correct
113 Correct 943 ms 321972 KB Output is correct
114 Correct 988 ms 322128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 479 ms 158132 KB Output is correct
2 Correct 1058 ms 322280 KB Output is correct
3 Correct 1025 ms 322400 KB Output is correct
4 Correct 951 ms 320908 KB Output is correct
5 Correct 1087 ms 322244 KB Output is correct
6 Correct 943 ms 322076 KB Output is correct
7 Correct 965 ms 321980 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 2 ms 1880 KB Output is correct
10 Correct 2 ms 1876 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 2 ms 1880 KB Output is correct
13 Correct 2 ms 1880 KB Output is correct
14 Correct 2 ms 1880 KB Output is correct
15 Correct 2 ms 1880 KB Output is correct
16 Correct 2 ms 1880 KB Output is correct
17 Correct 2 ms 1880 KB Output is correct
18 Correct 2 ms 2036 KB Output is correct
19 Correct 2 ms 1880 KB Output is correct
20 Correct 2 ms 1880 KB Output is correct
21 Correct 2 ms 1880 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 2 ms 1880 KB Output is correct
24 Correct 2 ms 1880 KB Output is correct
25 Correct 2 ms 1880 KB Output is correct
26 Correct 2 ms 1880 KB Output is correct
27 Correct 2 ms 1880 KB Output is correct
28 Correct 2 ms 1880 KB Output is correct
29 Correct 2 ms 1880 KB Output is correct
30 Correct 2 ms 1880 KB Output is correct
31 Correct 2 ms 1880 KB Output is correct
32 Correct 2 ms 1880 KB Output is correct
33 Correct 2 ms 1880 KB Output is correct
34 Correct 2 ms 1880 KB Output is correct
35 Correct 1 ms 856 KB Output is correct
36 Correct 2 ms 1880 KB Output is correct
37 Correct 2 ms 1880 KB Output is correct
38 Correct 2 ms 1880 KB Output is correct
39 Correct 2 ms 2132 KB Output is correct
40 Correct 2 ms 1880 KB Output is correct
41 Correct 3 ms 1880 KB Output is correct
42 Correct 2 ms 1880 KB Output is correct
43 Correct 2 ms 1880 KB Output is correct
44 Correct 2 ms 1880 KB Output is correct
45 Correct 2 ms 1880 KB Output is correct
46 Correct 92 ms 69560 KB Output is correct
47 Correct 155 ms 110676 KB Output is correct
48 Correct 157 ms 111016 KB Output is correct
49 Correct 153 ms 110760 KB Output is correct
50 Correct 160 ms 110708 KB Output is correct
51 Correct 157 ms 110744 KB Output is correct
52 Correct 157 ms 110748 KB Output is correct
53 Correct 111 ms 109976 KB Output is correct
54 Correct 112 ms 111116 KB Output is correct
55 Correct 108 ms 110480 KB Output is correct
56 Correct 111 ms 110956 KB Output is correct
57 Correct 160 ms 110764 KB Output is correct
58 Correct 157 ms 110752 KB Output is correct
59 Correct 166 ms 111072 KB Output is correct
60 Correct 112 ms 111256 KB Output is correct
61 Correct 110 ms 110000 KB Output is correct
62 Correct 167 ms 110764 KB Output is correct
63 Correct 156 ms 110768 KB Output is correct
64 Correct 166 ms 110764 KB Output is correct
65 Correct 113 ms 111300 KB Output is correct
66 Correct 108 ms 110800 KB Output is correct
67 Correct 150 ms 106920 KB Output is correct
68 Correct 155 ms 111000 KB Output is correct
69 Correct 159 ms 110884 KB Output is correct
70 Correct 192 ms 110704 KB Output is correct
71 Correct 152 ms 110920 KB Output is correct
72 Correct 166 ms 110700 KB Output is correct
73 Correct 154 ms 110760 KB Output is correct
74 Correct 106 ms 109976 KB Output is correct
75 Correct 115 ms 111276 KB Output is correct
76 Correct 111 ms 110752 KB Output is correct
77 Correct 110 ms 111276 KB Output is correct
78 Correct 847 ms 271420 KB Output is correct
79 Correct 997 ms 321800 KB Output is correct
80 Correct 1046 ms 321800 KB Output is correct
81 Correct 1048 ms 322052 KB Output is correct
82 Correct 1010 ms 322264 KB Output is correct
83 Correct 1006 ms 321940 KB Output is correct
84 Correct 1006 ms 322396 KB Output is correct
85 Correct 961 ms 320444 KB Output is correct
86 Correct 1018 ms 322224 KB Output is correct
87 Correct 963 ms 321344 KB Output is correct
88 Correct 1065 ms 322016 KB Output is correct
89 Correct 970 ms 321608 KB Output is correct
90 Correct 981 ms 322212 KB Output is correct
91 Correct 1 ms 340 KB Output is correct
92 Correct 2 ms 1880 KB Output is correct
93 Correct 2 ms 1880 KB Output is correct
94 Correct 168 ms 110812 KB Output is correct
95 Correct 160 ms 110928 KB Output is correct
96 Correct 164 ms 110900 KB Output is correct
97 Correct 118 ms 111268 KB Output is correct
98 Correct 117 ms 110108 KB Output is correct
99 Correct 163 ms 110796 KB Output is correct
100 Correct 163 ms 110756 KB Output is correct
101 Correct 176 ms 110720 KB Output is correct
102 Correct 113 ms 111260 KB Output is correct
103 Correct 109 ms 110596 KB Output is correct
104 Correct 2 ms 1880 KB Output is correct
105 Correct 3 ms 1964 KB Output is correct
106 Correct 2 ms 1880 KB Output is correct
107 Correct 2 ms 1876 KB Output is correct
108 Correct 2 ms 1880 KB Output is correct
109 Correct 2 ms 1880 KB Output is correct
110 Correct 2 ms 2012 KB Output is correct
111 Correct 2 ms 1880 KB Output is correct
112 Correct 2 ms 1880 KB Output is correct
113 Correct 2 ms 1880 KB Output is correct
114 Correct 242 ms 44828 KB Output is correct
115 Correct 948 ms 199708 KB Output is correct
116 Correct 937 ms 199460 KB Output is correct
117 Correct 887 ms 199288 KB Output is correct
118 Correct 921 ms 199472 KB Output is correct
119 Correct 899 ms 199300 KB Output is correct
120 Correct 873 ms 199676 KB Output is correct
121 Correct 776 ms 198644 KB Output is correct
122 Correct 815 ms 199920 KB Output is correct
123 Correct 782 ms 198976 KB Output is correct
124 Correct 808 ms 199736 KB Output is correct
125 Correct 193 ms 110836 KB Output is correct
126 Correct 215 ms 110712 KB Output is correct
127 Correct 159 ms 110760 KB Output is correct
128 Correct 112 ms 111228 KB Output is correct
129 Correct 112 ms 110572 KB Output is correct
130 Correct 164 ms 106960 KB Output is correct
131 Correct 159 ms 110956 KB Output is correct
132 Correct 165 ms 110904 KB Output is correct
133 Correct 155 ms 110784 KB Output is correct
134 Correct 157 ms 110776 KB Output is correct
135 Correct 184 ms 110752 KB Output is correct
136 Correct 158 ms 110744 KB Output is correct
137 Correct 116 ms 109984 KB Output is correct
138 Correct 116 ms 111096 KB Output is correct
139 Correct 116 ms 111024 KB Output is correct
140 Correct 112 ms 111260 KB Output is correct
141 Correct 3 ms 1880 KB Output is correct
142 Correct 2 ms 1960 KB Output is correct
143 Correct 2 ms 1880 KB Output is correct
144 Correct 2 ms 1880 KB Output is correct
145 Correct 2 ms 2136 KB Output is correct
146 Correct 1 ms 856 KB Output is correct
147 Correct 2 ms 1880 KB Output is correct
148 Correct 2 ms 1880 KB Output is correct
149 Correct 2 ms 1880 KB Output is correct
150 Correct 2 ms 1968 KB Output is correct
151 Correct 2 ms 1880 KB Output is correct
152 Correct 2 ms 2132 KB Output is correct
153 Correct 2 ms 1880 KB Output is correct
154 Correct 2 ms 1880 KB Output is correct
155 Correct 2 ms 1880 KB Output is correct
156 Correct 2 ms 1880 KB Output is correct
157 Correct 875 ms 276712 KB Output is correct
158 Correct 1055 ms 321828 KB Output is correct
159 Correct 992 ms 321924 KB Output is correct
160 Correct 1057 ms 322148 KB Output is correct
161 Correct 1033 ms 322188 KB Output is correct
162 Correct 1029 ms 322308 KB Output is correct
163 Correct 1100 ms 322092 KB Output is correct
164 Correct 957 ms 321304 KB Output is correct
165 Correct 960 ms 322068 KB Output is correct
166 Correct 943 ms 321972 KB Output is correct
167 Correct 988 ms 322128 KB Output is correct
168 Correct 0 ms 344 KB Output is correct
169 Correct 733 ms 166548 KB Output is correct
170 Correct 1281 ms 321868 KB Output is correct
171 Correct 1258 ms 321872 KB Output is correct
172 Correct 1223 ms 321840 KB Output is correct
173 Correct 1254 ms 321832 KB Output is correct
174 Correct 1205 ms 321676 KB Output is correct
175 Correct 1262 ms 322236 KB Output is correct
176 Correct 960 ms 320592 KB Output is correct
177 Correct 1079 ms 321604 KB Output is correct
178 Correct 1066 ms 321644 KB Output is correct
179 Correct 1065 ms 321652 KB Output is correct