Submission #999460

# Submission time Handle Problem Language Result Execution time Memory
999460 2024-06-15T14:09:38 Z mc061 Diversity (CEOI21_diversity) C++17
100 / 100
1204 ms 5576 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#pragma GCC optimize("Ofast,unroll-loops")
#ifndef ONLINE_JUDGE
    // #include "debug.h"
#else
    #define dbg(...) 42
    template<typename T>ostream&operator<<(ostream&os,vector<T>&vec){for(int i=0;i+1<vec.size();++i){os<<vec[i]<<" ";}if(vec.size()>0)os<<vec.back();return os;}
#endif

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template<typename T>istream&operator>>(istream&is,vector<T>&vec){for(T&element:vec){is>>element;}return is;}
template<typename T>void chmin(T&x,T y){x=min(x,y);}
template<typename T>void chmax(T&x,T y){x=max(x,y);}

const int N = 3e5+6;
const int Qn = 1337;
const int block = 2000;
int ar[N];
int qu_lengths[Qn];
int qu_cnt[Qn];
int cnt[N];
int mp[N];
int64_t qAns[N];
bitset<N> bs;

set<int> lengths;

void rem_c(int c) {
    mp[c]--;
    if (mp[c] == 0) bs[c] = 0;
}

void add(int val) {
    if (cnt[val] != 0)
        rem_c(cnt[val]);
    cnt[val]++;
    mp[cnt[val]]++;
    if (mp[cnt[val]] == 1) bs[cnt[val]] = 1;
}

void rem(int val) {
    rem_c(cnt[val]);
    cnt[val]--;
    if (cnt[val] != 0) {
        mp[cnt[val]]++;
        if (mp[cnt[val]] == 1) bs[cnt[val]] = 1;
    }
}

struct segment {
    int length;
    int diffs;
    int64_t ans;
    int64_t ans_left;
    int64_t ans_right;
};

segment merge_two(segment A, segment B) {
    if (A.length == 0) return B;
    if (B.length == 0) return A;
    segment res;
    res.diffs = A.diffs + B.diffs;
    res.length = A.length + B.length;
    res.ans_right = B.ans_right + 1ll*A.ans_right + 1ll*(B.diffs)*A.length;
    res.ans_left = A.ans_left + 1ll*B.ans_left + 1ll*(A.diffs)*B.length;
    res.ans = A.ans + B.ans + 1ll*A.ans_right*B.length + 1ll*B.ans_left*A.length;
    return res;
}

segment form_one(int length, int cnt) {
    segment cur = segment{length, 1, 1ll*length*(length+1)/2, length, length};
    segment res = {0, 0, 0, 0, 0};
    for (; cnt > 0; cnt >>= 1) {
        if (cnt & 1) {
            res = merge_two(res, cur);
        }
        cur = merge_two(cur, cur);
    }
    return res;
}

void go(int ind) {
    vector<int> lengths;
    for (int i = bs._Find_first(); i < bs.size(); i = bs._Find_next(i)) lengths.push_back(i);
    memset(qu_lengths, 0, sizeof(qu_lengths));
    memset(qu_cnt, 0, sizeof(qu_cnt));
    bool odd_to_left = true;
    int ptr = 0;
    for (int le : lengths) {
        int c = mp[le];
        int to_left = c / 2;
        int to_right = c / 2;
        if (c % 2 != 0) {
            if (odd_to_left) {
                to_left++;
            }
            else {
                to_right++;
            }
            odd_to_left ^= 1;
        }
        qu_lengths[ptr] = le;
        qu_lengths[Qn - ptr - 1] = le;
        qu_cnt[ptr] = to_left;
        qu_cnt[Qn - ptr - 1] = to_right;
        ++ptr;
    }
    segment res{0, 0, 0, 0, 0};
    for (int i = 0; i < Qn; ++i) {
        if (qu_cnt[i] == 0) continue;
        segment now = form_one(qu_lengths[i], qu_cnt[i]);
        res = merge_two(res, now);
    }
    qAns[ind] = res.ans;
}

void test_case(signed num) {
    int n, q;
    cin >> n >> q;
    for (int i = 0; i < n; ++i) {
        cin >> ar[i];
    }
    vector<array<int, 3>> queries;
    for (int i = 0; i < q; ++i) {
        int l, r;
        cin >> l >> r;
        --l, --r;
        queries.push_back({l, r, i});
    }
    sort(queries.begin(), queries.end(), [&] (const array<int, 3>& a, const array<int, 3>& b) {
        return make_pair(a[0] / block, a[1]) < make_pair(b[0] / block, b[1]); 
    });

    int ql = 0, qr = -1;

    for (int i = 0; i < queries.size(); ++i) {
        while (ql > queries[i][0]) {
            --ql;
            add(ar[ql]);
        }
        while (qr < queries[i][1]) {
            ++qr;
            add(ar[qr]);
        }
        while (ql < queries[i][0]) {
            rem(ar[ql]);
            ++ql;
        }
        while (qr > queries[i][1]) {
            rem(ar[qr]);
            --qr;
        }

        go(queries[i][2]);
    }
    for (int i = 0; i < q; ++i) {
        cout << qAns[i] << "\n";
    }
}

signed main(void) {
    cin.tie(0)->sync_with_stdio(false);

    test_case(69420);
}

Compilation message

diversity.cpp: In function 'void go(int)':
diversity.cpp:88:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::size_t' {aka 'long unsigned int'} [-Wsign-compare]
   88 |     for (int i = bs._Find_first(); i < bs.size(); i = bs._Find_next(i)) lengths.push_back(i);
      |                                    ~~^~~~~~~~~~~
diversity.cpp: In function 'void test_case(int)':
diversity.cpp:140:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  140 |     for (int i = 0; i < queries.size(); ++i) {
      |                     ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 428 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 4 ms 860 KB Output is correct
5 Correct 8 ms 1524 KB Output is correct
6 Correct 12 ms 1884 KB Output is correct
7 Correct 12 ms 2140 KB Output is correct
8 Correct 15 ms 1628 KB Output is correct
9 Correct 12 ms 1884 KB Output is correct
10 Correct 12 ms 1884 KB Output is correct
11 Correct 14 ms 1884 KB Output is correct
12 Correct 13 ms 1732 KB Output is correct
13 Correct 12 ms 1812 KB Output is correct
14 Correct 12 ms 1800 KB Output is correct
15 Correct 12 ms 1884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 4 ms 860 KB Output is correct
5 Correct 8 ms 1524 KB Output is correct
6 Correct 12 ms 1884 KB Output is correct
7 Correct 12 ms 2140 KB Output is correct
8 Correct 15 ms 1628 KB Output is correct
9 Correct 12 ms 1884 KB Output is correct
10 Correct 12 ms 1884 KB Output is correct
11 Correct 14 ms 1884 KB Output is correct
12 Correct 13 ms 1732 KB Output is correct
13 Correct 12 ms 1812 KB Output is correct
14 Correct 12 ms 1800 KB Output is correct
15 Correct 12 ms 1884 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 4 ms 896 KB Output is correct
20 Correct 11 ms 1248 KB Output is correct
21 Correct 17 ms 1816 KB Output is correct
22 Correct 13 ms 1624 KB Output is correct
23 Correct 14 ms 1624 KB Output is correct
24 Correct 14 ms 1628 KB Output is correct
25 Correct 13 ms 1764 KB Output is correct
26 Correct 14 ms 1752 KB Output is correct
27 Correct 15 ms 1704 KB Output is correct
28 Correct 13 ms 1884 KB Output is correct
29 Correct 13 ms 1628 KB Output is correct
30 Correct 12 ms 1628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 4 ms 860 KB Output is correct
5 Correct 8 ms 1524 KB Output is correct
6 Correct 12 ms 1884 KB Output is correct
7 Correct 12 ms 2140 KB Output is correct
8 Correct 15 ms 1628 KB Output is correct
9 Correct 12 ms 1884 KB Output is correct
10 Correct 12 ms 1884 KB Output is correct
11 Correct 14 ms 1884 KB Output is correct
12 Correct 13 ms 1732 KB Output is correct
13 Correct 12 ms 1812 KB Output is correct
14 Correct 12 ms 1800 KB Output is correct
15 Correct 12 ms 1884 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 4 ms 896 KB Output is correct
20 Correct 11 ms 1248 KB Output is correct
21 Correct 17 ms 1816 KB Output is correct
22 Correct 13 ms 1624 KB Output is correct
23 Correct 14 ms 1624 KB Output is correct
24 Correct 14 ms 1628 KB Output is correct
25 Correct 13 ms 1764 KB Output is correct
26 Correct 14 ms 1752 KB Output is correct
27 Correct 15 ms 1704 KB Output is correct
28 Correct 13 ms 1884 KB Output is correct
29 Correct 13 ms 1628 KB Output is correct
30 Correct 12 ms 1628 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 2 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 3 ms 604 KB Output is correct
38 Correct 2 ms 604 KB Output is correct
39 Correct 5 ms 860 KB Output is correct
40 Correct 11 ms 1268 KB Output is correct
41 Correct 16 ms 1460 KB Output is correct
42 Correct 14 ms 1628 KB Output is correct
43 Correct 15 ms 1628 KB Output is correct
44 Correct 16 ms 1624 KB Output is correct
45 Correct 16 ms 1624 KB Output is correct
46 Correct 15 ms 1624 KB Output is correct
47 Correct 16 ms 1628 KB Output is correct
48 Correct 15 ms 1628 KB Output is correct
49 Correct 15 ms 1664 KB Output is correct
50 Correct 16 ms 1584 KB Output is correct
51 Correct 15 ms 1632 KB Output is correct
52 Correct 16 ms 1628 KB Output is correct
53 Correct 15 ms 1628 KB Output is correct
54 Correct 15 ms 1628 KB Output is correct
55 Correct 16 ms 1628 KB Output is correct
56 Correct 16 ms 1524 KB Output is correct
57 Correct 21 ms 1628 KB Output is correct
58 Correct 16 ms 1628 KB Output is correct
59 Correct 15 ms 1628 KB Output is correct
60 Correct 15 ms 1628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 428 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 4 ms 860 KB Output is correct
15 Correct 8 ms 1524 KB Output is correct
16 Correct 12 ms 1884 KB Output is correct
17 Correct 12 ms 2140 KB Output is correct
18 Correct 15 ms 1628 KB Output is correct
19 Correct 12 ms 1884 KB Output is correct
20 Correct 12 ms 1884 KB Output is correct
21 Correct 14 ms 1884 KB Output is correct
22 Correct 13 ms 1732 KB Output is correct
23 Correct 12 ms 1812 KB Output is correct
24 Correct 12 ms 1800 KB Output is correct
25 Correct 12 ms 1884 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 4 ms 896 KB Output is correct
30 Correct 11 ms 1248 KB Output is correct
31 Correct 17 ms 1816 KB Output is correct
32 Correct 13 ms 1624 KB Output is correct
33 Correct 14 ms 1624 KB Output is correct
34 Correct 14 ms 1628 KB Output is correct
35 Correct 13 ms 1764 KB Output is correct
36 Correct 14 ms 1752 KB Output is correct
37 Correct 15 ms 1704 KB Output is correct
38 Correct 13 ms 1884 KB Output is correct
39 Correct 13 ms 1628 KB Output is correct
40 Correct 12 ms 1628 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 2 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 3 ms 604 KB Output is correct
48 Correct 2 ms 604 KB Output is correct
49 Correct 5 ms 860 KB Output is correct
50 Correct 11 ms 1268 KB Output is correct
51 Correct 16 ms 1460 KB Output is correct
52 Correct 14 ms 1628 KB Output is correct
53 Correct 15 ms 1628 KB Output is correct
54 Correct 16 ms 1624 KB Output is correct
55 Correct 16 ms 1624 KB Output is correct
56 Correct 15 ms 1624 KB Output is correct
57 Correct 16 ms 1628 KB Output is correct
58 Correct 15 ms 1628 KB Output is correct
59 Correct 15 ms 1664 KB Output is correct
60 Correct 16 ms 1584 KB Output is correct
61 Correct 15 ms 1632 KB Output is correct
62 Correct 16 ms 1628 KB Output is correct
63 Correct 15 ms 1628 KB Output is correct
64 Correct 15 ms 1628 KB Output is correct
65 Correct 16 ms 1628 KB Output is correct
66 Correct 16 ms 1524 KB Output is correct
67 Correct 21 ms 1628 KB Output is correct
68 Correct 16 ms 1628 KB Output is correct
69 Correct 15 ms 1628 KB Output is correct
70 Correct 15 ms 1628 KB Output is correct
71 Correct 3 ms 604 KB Output is correct
72 Correct 3 ms 604 KB Output is correct
73 Correct 4 ms 604 KB Output is correct
74 Correct 3 ms 600 KB Output is correct
75 Correct 3 ms 604 KB Output is correct
76 Correct 5 ms 708 KB Output is correct
77 Correct 5 ms 860 KB Output is correct
78 Correct 5 ms 780 KB Output is correct
79 Correct 6 ms 856 KB Output is correct
80 Correct 9 ms 1112 KB Output is correct
81 Correct 9 ms 1112 KB Output is correct
82 Correct 10 ms 1112 KB Output is correct
83 Correct 10 ms 1112 KB Output is correct
84 Correct 9 ms 1112 KB Output is correct
85 Correct 10 ms 1112 KB Output is correct
86 Correct 12 ms 1112 KB Output is correct
87 Correct 11 ms 1116 KB Output is correct
88 Correct 11 ms 1116 KB Output is correct
89 Correct 12 ms 1112 KB Output is correct
90 Correct 11 ms 1116 KB Output is correct
91 Correct 17 ms 1884 KB Output is correct
92 Correct 18 ms 1884 KB Output is correct
93 Correct 16 ms 1884 KB Output is correct
94 Correct 16 ms 1964 KB Output is correct
95 Correct 23 ms 2040 KB Output is correct
96 Correct 25 ms 2388 KB Output is correct
97 Correct 20 ms 2396 KB Output is correct
98 Correct 19 ms 2380 KB Output is correct
99 Correct 20 ms 2396 KB Output is correct
100 Correct 21 ms 2332 KB Output is correct
101 Correct 19 ms 2360 KB Output is correct
102 Correct 19 ms 2396 KB Output is correct
103 Correct 19 ms 2392 KB Output is correct
104 Correct 19 ms 2396 KB Output is correct
105 Correct 19 ms 2200 KB Output is correct
106 Correct 19 ms 2392 KB Output is correct
107 Correct 19 ms 2420 KB Output is correct
108 Correct 19 ms 2396 KB Output is correct
109 Correct 26 ms 2396 KB Output is correct
110 Correct 19 ms 2396 KB Output is correct
111 Correct 18 ms 2396 KB Output is correct
112 Correct 18 ms 2404 KB Output is correct
113 Correct 19 ms 2428 KB Output is correct
114 Correct 19 ms 2388 KB Output is correct
115 Correct 20 ms 2616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 428 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 4 ms 860 KB Output is correct
15 Correct 8 ms 1524 KB Output is correct
16 Correct 12 ms 1884 KB Output is correct
17 Correct 12 ms 2140 KB Output is correct
18 Correct 15 ms 1628 KB Output is correct
19 Correct 12 ms 1884 KB Output is correct
20 Correct 12 ms 1884 KB Output is correct
21 Correct 14 ms 1884 KB Output is correct
22 Correct 13 ms 1732 KB Output is correct
23 Correct 12 ms 1812 KB Output is correct
24 Correct 12 ms 1800 KB Output is correct
25 Correct 12 ms 1884 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 4 ms 896 KB Output is correct
30 Correct 11 ms 1248 KB Output is correct
31 Correct 17 ms 1816 KB Output is correct
32 Correct 13 ms 1624 KB Output is correct
33 Correct 14 ms 1624 KB Output is correct
34 Correct 14 ms 1628 KB Output is correct
35 Correct 13 ms 1764 KB Output is correct
36 Correct 14 ms 1752 KB Output is correct
37 Correct 15 ms 1704 KB Output is correct
38 Correct 13 ms 1884 KB Output is correct
39 Correct 13 ms 1628 KB Output is correct
40 Correct 12 ms 1628 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 2 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 3 ms 604 KB Output is correct
48 Correct 2 ms 604 KB Output is correct
49 Correct 5 ms 860 KB Output is correct
50 Correct 11 ms 1268 KB Output is correct
51 Correct 16 ms 1460 KB Output is correct
52 Correct 14 ms 1628 KB Output is correct
53 Correct 15 ms 1628 KB Output is correct
54 Correct 16 ms 1624 KB Output is correct
55 Correct 16 ms 1624 KB Output is correct
56 Correct 15 ms 1624 KB Output is correct
57 Correct 16 ms 1628 KB Output is correct
58 Correct 15 ms 1628 KB Output is correct
59 Correct 15 ms 1664 KB Output is correct
60 Correct 16 ms 1584 KB Output is correct
61 Correct 15 ms 1632 KB Output is correct
62 Correct 16 ms 1628 KB Output is correct
63 Correct 15 ms 1628 KB Output is correct
64 Correct 15 ms 1628 KB Output is correct
65 Correct 16 ms 1628 KB Output is correct
66 Correct 16 ms 1524 KB Output is correct
67 Correct 21 ms 1628 KB Output is correct
68 Correct 16 ms 1628 KB Output is correct
69 Correct 15 ms 1628 KB Output is correct
70 Correct 15 ms 1628 KB Output is correct
71 Correct 3 ms 604 KB Output is correct
72 Correct 3 ms 604 KB Output is correct
73 Correct 4 ms 604 KB Output is correct
74 Correct 3 ms 600 KB Output is correct
75 Correct 3 ms 604 KB Output is correct
76 Correct 5 ms 708 KB Output is correct
77 Correct 5 ms 860 KB Output is correct
78 Correct 5 ms 780 KB Output is correct
79 Correct 6 ms 856 KB Output is correct
80 Correct 9 ms 1112 KB Output is correct
81 Correct 9 ms 1112 KB Output is correct
82 Correct 10 ms 1112 KB Output is correct
83 Correct 10 ms 1112 KB Output is correct
84 Correct 9 ms 1112 KB Output is correct
85 Correct 10 ms 1112 KB Output is correct
86 Correct 12 ms 1112 KB Output is correct
87 Correct 11 ms 1116 KB Output is correct
88 Correct 11 ms 1116 KB Output is correct
89 Correct 12 ms 1112 KB Output is correct
90 Correct 11 ms 1116 KB Output is correct
91 Correct 17 ms 1884 KB Output is correct
92 Correct 18 ms 1884 KB Output is correct
93 Correct 16 ms 1884 KB Output is correct
94 Correct 16 ms 1964 KB Output is correct
95 Correct 23 ms 2040 KB Output is correct
96 Correct 25 ms 2388 KB Output is correct
97 Correct 20 ms 2396 KB Output is correct
98 Correct 19 ms 2380 KB Output is correct
99 Correct 20 ms 2396 KB Output is correct
100 Correct 21 ms 2332 KB Output is correct
101 Correct 19 ms 2360 KB Output is correct
102 Correct 19 ms 2396 KB Output is correct
103 Correct 19 ms 2392 KB Output is correct
104 Correct 19 ms 2396 KB Output is correct
105 Correct 19 ms 2200 KB Output is correct
106 Correct 19 ms 2392 KB Output is correct
107 Correct 19 ms 2420 KB Output is correct
108 Correct 19 ms 2396 KB Output is correct
109 Correct 26 ms 2396 KB Output is correct
110 Correct 19 ms 2396 KB Output is correct
111 Correct 18 ms 2396 KB Output is correct
112 Correct 18 ms 2404 KB Output is correct
113 Correct 19 ms 2428 KB Output is correct
114 Correct 19 ms 2388 KB Output is correct
115 Correct 20 ms 2616 KB Output is correct
116 Correct 378 ms 3780 KB Output is correct
117 Correct 411 ms 3784 KB Output is correct
118 Correct 454 ms 4296 KB Output is correct
119 Correct 513 ms 4036 KB Output is correct
120 Correct 403 ms 4100 KB Output is correct
121 Correct 557 ms 4292 KB Output is correct
122 Correct 448 ms 4296 KB Output is correct
123 Correct 845 ms 4808 KB Output is correct
124 Correct 507 ms 4716 KB Output is correct
125 Correct 462 ms 4736 KB Output is correct
126 Correct 957 ms 5176 KB Output is correct
127 Correct 965 ms 5320 KB Output is correct
128 Correct 955 ms 5100 KB Output is correct
129 Correct 964 ms 5060 KB Output is correct
130 Correct 990 ms 5316 KB Output is correct
131 Correct 1153 ms 5084 KB Output is correct
132 Correct 1203 ms 5100 KB Output is correct
133 Correct 1184 ms 5084 KB Output is correct
134 Correct 1174 ms 5088 KB Output is correct
135 Correct 1179 ms 5316 KB Output is correct
136 Correct 1185 ms 5112 KB Output is correct
137 Correct 1204 ms 5092 KB Output is correct
138 Correct 1171 ms 5064 KB Output is correct
139 Correct 1192 ms 5092 KB Output is correct
140 Correct 1200 ms 5320 KB Output is correct
141 Correct 1068 ms 5064 KB Output is correct
142 Correct 1106 ms 5172 KB Output is correct
143 Correct 1086 ms 5064 KB Output is correct
144 Correct 1105 ms 5320 KB Output is correct
145 Correct 1102 ms 5092 KB Output is correct
146 Correct 650 ms 5064 KB Output is correct
147 Correct 648 ms 5064 KB Output is correct
148 Correct 654 ms 5068 KB Output is correct
149 Correct 640 ms 5060 KB Output is correct
150 Correct 652 ms 5064 KB Output is correct
151 Correct 620 ms 5108 KB Output is correct
152 Correct 603 ms 5252 KB Output is correct
153 Correct 583 ms 5108 KB Output is correct
154 Correct 591 ms 5064 KB Output is correct
155 Correct 579 ms 5068 KB Output is correct
156 Correct 1060 ms 5572 KB Output is correct
157 Correct 1102 ms 5464 KB Output is correct
158 Correct 1038 ms 5316 KB Output is correct
159 Correct 1103 ms 5496 KB Output is correct
160 Correct 1070 ms 5320 KB Output is correct
161 Correct 844 ms 5576 KB Output is correct
162 Correct 885 ms 5312 KB Output is correct
163 Correct 834 ms 5432 KB Output is correct
164 Correct 833 ms 5320 KB Output is correct
165 Correct 837 ms 5288 KB Output is correct
166 Correct 1127 ms 5124 KB Output is correct
167 Correct 1126 ms 5120 KB Output is correct
168 Correct 1136 ms 5072 KB Output is correct
169 Correct 1146 ms 5148 KB Output is correct
170 Correct 1141 ms 5064 KB Output is correct
171 Correct 963 ms 5064 KB Output is correct
172 Correct 1026 ms 5060 KB Output is correct
173 Correct 988 ms 5136 KB Output is correct
174 Correct 956 ms 5152 KB Output is correct
175 Correct 992 ms 5044 KB Output is correct