Submission #763704

# Submission time Handle Problem Language Result Execution time Memory
763704 2023-06-22T16:26:26 Z vjudge1 Tourism (JOI23_tourism) C++17
100 / 100
997 ms 111808 KB
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
*/
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define len(x) ll(x.size())
#define eb emplace_back
#define PI acos(-1.0)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define BIT(x, i) (1 & ((x) >> (i)))
#define MASK(x) (1LL << (x))
#define task "tnc"
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const int maxn = 3e5 + 5;
const int mod = 1e9 + 7;
const int mo = 998244353;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using pii = pair<pair<ll, ll>, ll>;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int tin[maxn];
int tout[maxn];
int eu[maxn];
int n, m, q;
int ti = 0;
vector<int> G[maxn];
int h[maxn];
void dfs(int u, int pa)
{
    tin[u] = ++ti;
    eu[ti] = u;
    for (auto v : G[u])
    {
        if (v == pa)
            continue;
        h[v] = h[u] + 1;
        dfs(v, u);
        eu[++ti] = u;
    }
}
pair<int, int> rmq[maxn][19];
void init()
{
    for (int i = 1; i <= ti; i++)
    {
        rmq[i][0] = {tin[eu[i]], eu[i]};
    }
    for (int j = 1; (1 << j) <= ti; j++)
    {
        for (int i = 1; i <= ti; i++)
        {
            rmq[i][j] = min(rmq[i][j - 1], rmq[i + (1 << (j - 1))][j - 1]);
        }
    }
}
int LCA(int u, int v)
{
    if (tin[u] > tin[v])
        swap(u, v);
    int k = 31 - __builtin_clz(tin[v] - tin[u] + 1);
    return min(rmq[tin[u]][k], rmq[tin[v] - (1 << k) + 1][k]).se;
}
struct que
{
    int l, r, id;
    que() {}
    que(int _l, int _r, int _id)
    {
        l = _l;
        r = _r;
        id = _id;
    }
};
// BIT
int bit[maxn];
void update(int id, int val)
{
    for (id; id >= 1; id -= id & (-id))
    {
        bit[id] += val;
    }
}
int get(int id)
{
    int res = 0;
    for (id; id <= m; id += id & (-id))
    {
        res += bit[id];
    }
    return res;
}
vector<que> st[maxn];
void update(int l, int r, int u, int v, int id)
{
    if (l <= r)
    {
        int mid = (l + r) / 2;
        if (u <= mid && mid <= v)
        {
            st[mid].pb(que(u, v, id));
            return;
        }
        if (v < mid)
            update(l, mid - 1, u, v, id);
        else
            update(mid + 1, r, u, v, id);
    }
}
vector<int> d[maxn];
vector<int> adj[maxn];
int befmid[maxn];
int aftmid[maxn];
int prefbef[maxn];
int prefaft[maxn];
vector<pair<int, int>> ask[maxn];
vector<pair<int, int>> ques[maxn];
void dfs1(int u, int pa, int mid, int l, int r)
{
    auto z = lower_bound(d[u].begin(), d[u].end(), mid) - d[u].begin();

    if (z < d[u].size())
    {
        aftmid[u] = d[u][z];
    }
    else
    {
        aftmid[u] = 1e9;
    }
    if (z != 0)
    {
        z--;
        befmid[u] = d[u][z];
    }

    for (auto v : adj[u])
    {
        if (v == pa)
            continue;
        dfs1(v, u, mid, l, r);

        befmid[u] = max(befmid[v], befmid[u]);
        aftmid[u] = min(aftmid[u], aftmid[v]);

        if (befmid[v] >= l)
        {
            prefbef[befmid[v]] += abs(h[v] - h[u]);
        }

        if (aftmid[v] <= r)
        {
            prefaft[aftmid[v]] += abs(h[v] - h[u]);
        }

        if (befmid[v] >= l && aftmid[v] <= r)
        {
            ask[aftmid[v]].pb({befmid[v], abs(h[v] - h[u])});
        }
    }
}
int ans[maxn];
int c[maxn];
bool cmp(int u, int v)
{
    return tin[u] < tin[v];
}
void DNC(int l, int r)
{
    if (l <= r)
    {

        int mid = (l + r) / 2;
        vector<int> ver;
        for (int i = l; i <= r; i++)
        {
            ver.pb(c[i]);
        }
        sort(ver.begin(), ver.end());
        ver.resize(distance(ver.begin(), unique(ver.begin(), ver.end())));
        sort(ver.begin(), ver.end(), cmp);
        vector<int> vir;
        vir = ver;
        for (auto i = 1; i < ver.size(); i++)
        {
            vir.pb(LCA(ver[i], ver[i - 1]));
        }
        sort(vir.begin(), vir.end());
        vir.resize(distance(vir.begin(), unique(vir.begin(), vir.end())));
        sort(vir.begin(), vir.end(), cmp);

        for (int i = 1; i < vir.size(); i++)
        {
            adj[LCA(vir[i], vir[i - 1])].pb(vir[i]);
            adj[vir[i]].pb(LCA(vir[i], vir[i - 1]));
        }
        dfs1(c[mid], -1, mid, l, r);
        for (int i = mid; i >= l; i--)
        {
            prefbef[i] += prefbef[i + 1];
        }
        for (int i = mid; i <= r; i++)
        {
            prefaft[i] += prefaft[i - 1];
        }
        for (auto v : st[mid])
        {
            ques[v.r].pb({v.l, v.id});
        }
        for (int i = mid; i <= r; i++)
        {
            for (auto v : ask[i])
            {
                update(v.fi, v.se);
            }
            for (auto v : ques[i])
            {
                ans[v.se] = prefbef[v.fi] + prefaft[i] - get(v.fi);
            }
            ques[i].clear();
        }
        for (int i = mid; i >= l; i--)
        {
            prefbef[i] = 0;
        }
        for (int i = mid; i <= r; i++)
        {
            prefaft[i] = 0;
            for (auto v : ask[i])
            {
                update(v.fi, -v.se);
            }
            ask[i].clear();
        }
        for (auto v : vir)
        {
            aftmid[v] = 0;
            befmid[v] = 0;
            adj[v].clear();
        }

        if (l != r)
        {
            DNC(l, mid - 1);
            DNC(mid + 1, r);
        }
    }
}

signed main()
{
    cin.tie(0), cout.tie(0)->sync_with_stdio(0);
    cin >> n >> m >> q;
    for (int i = 1; i < n; i++)
    {
        int u, v;
        cin >> u >> v;
        G[u].pb(v);
        G[v].pb(u);
    }
    for (int i = 1; i <= m; i++)
    {
        cin >> c[i];
        d[c[i]].pb(i);
    }
    for (int i = 1; i <= q; i++)
    {
        int l, r;
        cin >> l >> r;
        update(1, m, l, r, i);
    }
    dfs(1, -1);
    init();

    DNC(1, m);
    for (int i = 1; i <= q; i++)
    {
        cout << ans[i] + 1 << "\n";
    }
}

Compilation message

tourism.cpp: In function 'void update(int, int)':
tourism.cpp:90:10: warning: statement has no effect [-Wunused-value]
   90 |     for (id; id >= 1; id -= id & (-id))
      |          ^~
tourism.cpp: In function 'int get(int)':
tourism.cpp:98:10: warning: statement has no effect [-Wunused-value]
   98 |     for (id; id <= m; id += id & (-id))
      |          ^~
tourism.cpp: In function 'void dfs1(int, int, int, int, int)':
tourism.cpp:133:11: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  133 |     if (z < d[u].size())
      |         ~~^~~~~~~~~~~~~
tourism.cpp: In function 'void DNC(int, int)':
tourism.cpp:194:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  194 |         for (auto i = 1; i < ver.size(); i++)
      |                          ~~^~~~~~~~~~~~
tourism.cpp:202:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  202 |         for (int i = 1; i < vir.size(); i++)
      |                         ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 21 ms 42580 KB Output is correct
2 Correct 24 ms 42624 KB Output is correct
3 Correct 20 ms 42660 KB Output is correct
4 Correct 22 ms 42744 KB Output is correct
5 Correct 21 ms 42776 KB Output is correct
6 Correct 21 ms 42680 KB Output is correct
7 Correct 22 ms 42672 KB Output is correct
8 Correct 25 ms 42780 KB Output is correct
9 Correct 23 ms 42816 KB Output is correct
10 Correct 23 ms 42764 KB Output is correct
11 Correct 22 ms 42800 KB Output is correct
12 Correct 22 ms 42708 KB Output is correct
13 Correct 23 ms 42724 KB Output is correct
14 Correct 22 ms 42708 KB Output is correct
15 Correct 22 ms 42848 KB Output is correct
16 Correct 22 ms 42776 KB Output is correct
17 Correct 23 ms 42820 KB Output is correct
18 Correct 21 ms 42748 KB Output is correct
19 Correct 23 ms 42728 KB Output is correct
20 Correct 22 ms 42836 KB Output is correct
21 Correct 25 ms 42768 KB Output is correct
22 Correct 22 ms 42724 KB Output is correct
23 Correct 21 ms 42828 KB Output is correct
24 Correct 26 ms 42712 KB Output is correct
25 Correct 22 ms 42776 KB Output is correct
26 Correct 22 ms 42828 KB Output is correct
27 Correct 22 ms 42580 KB Output is correct
28 Correct 21 ms 42728 KB Output is correct
29 Correct 23 ms 42832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 42580 KB Output is correct
2 Correct 24 ms 42624 KB Output is correct
3 Correct 20 ms 42660 KB Output is correct
4 Correct 22 ms 42744 KB Output is correct
5 Correct 21 ms 42776 KB Output is correct
6 Correct 21 ms 42680 KB Output is correct
7 Correct 22 ms 42672 KB Output is correct
8 Correct 25 ms 42780 KB Output is correct
9 Correct 23 ms 42816 KB Output is correct
10 Correct 23 ms 42764 KB Output is correct
11 Correct 22 ms 42800 KB Output is correct
12 Correct 22 ms 42708 KB Output is correct
13 Correct 23 ms 42724 KB Output is correct
14 Correct 22 ms 42708 KB Output is correct
15 Correct 22 ms 42848 KB Output is correct
16 Correct 22 ms 42776 KB Output is correct
17 Correct 23 ms 42820 KB Output is correct
18 Correct 21 ms 42748 KB Output is correct
19 Correct 23 ms 42728 KB Output is correct
20 Correct 22 ms 42836 KB Output is correct
21 Correct 25 ms 42768 KB Output is correct
22 Correct 22 ms 42724 KB Output is correct
23 Correct 21 ms 42828 KB Output is correct
24 Correct 26 ms 42712 KB Output is correct
25 Correct 22 ms 42776 KB Output is correct
26 Correct 22 ms 42828 KB Output is correct
27 Correct 22 ms 42580 KB Output is correct
28 Correct 21 ms 42728 KB Output is correct
29 Correct 23 ms 42832 KB Output is correct
30 Correct 28 ms 43348 KB Output is correct
31 Correct 26 ms 43452 KB Output is correct
32 Correct 28 ms 43680 KB Output is correct
33 Correct 29 ms 43660 KB Output is correct
34 Correct 29 ms 43604 KB Output is correct
35 Correct 28 ms 43604 KB Output is correct
36 Correct 29 ms 43612 KB Output is correct
37 Correct 29 ms 43664 KB Output is correct
38 Correct 28 ms 43900 KB Output is correct
39 Correct 28 ms 43908 KB Output is correct
40 Correct 32 ms 44056 KB Output is correct
41 Correct 28 ms 43804 KB Output is correct
42 Correct 28 ms 43836 KB Output is correct
43 Correct 28 ms 43860 KB Output is correct
44 Correct 34 ms 43756 KB Output is correct
45 Correct 28 ms 43772 KB Output is correct
46 Correct 27 ms 43716 KB Output is correct
47 Correct 28 ms 43732 KB Output is correct
48 Correct 28 ms 43684 KB Output is correct
49 Correct 28 ms 43724 KB Output is correct
50 Correct 26 ms 43560 KB Output is correct
51 Correct 26 ms 43592 KB Output is correct
52 Correct 29 ms 43640 KB Output is correct
53 Correct 27 ms 43604 KB Output is correct
54 Correct 27 ms 43660 KB Output is correct
55 Correct 27 ms 43648 KB Output is correct
56 Correct 23 ms 42708 KB Output is correct
57 Correct 22 ms 43376 KB Output is correct
58 Correct 29 ms 43604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 42580 KB Output is correct
2 Correct 20 ms 42580 KB Output is correct
3 Correct 20 ms 42708 KB Output is correct
4 Correct 452 ms 87188 KB Output is correct
5 Correct 327 ms 92184 KB Output is correct
6 Correct 468 ms 101836 KB Output is correct
7 Correct 588 ms 110576 KB Output is correct
8 Correct 586 ms 110484 KB Output is correct
9 Correct 595 ms 110716 KB Output is correct
10 Correct 583 ms 110652 KB Output is correct
11 Correct 581 ms 110596 KB Output is correct
12 Correct 397 ms 101492 KB Output is correct
13 Correct 395 ms 101460 KB Output is correct
14 Correct 392 ms 101428 KB Output is correct
15 Correct 99 ms 88416 KB Output is correct
16 Correct 665 ms 111808 KB Output is correct
17 Correct 103 ms 48548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 42648 KB Output is correct
2 Correct 425 ms 68960 KB Output is correct
3 Correct 722 ms 74356 KB Output is correct
4 Correct 543 ms 75208 KB Output is correct
5 Correct 901 ms 90772 KB Output is correct
6 Correct 888 ms 90928 KB Output is correct
7 Correct 884 ms 90884 KB Output is correct
8 Correct 894 ms 90640 KB Output is correct
9 Correct 918 ms 90904 KB Output is correct
10 Correct 952 ms 91036 KB Output is correct
11 Correct 899 ms 90864 KB Output is correct
12 Correct 940 ms 91240 KB Output is correct
13 Correct 910 ms 91324 KB Output is correct
14 Correct 934 ms 92508 KB Output is correct
15 Correct 926 ms 97436 KB Output is correct
16 Correct 896 ms 91440 KB Output is correct
17 Correct 930 ms 91436 KB Output is correct
18 Correct 923 ms 91340 KB Output is correct
19 Correct 854 ms 95288 KB Output is correct
20 Correct 861 ms 95408 KB Output is correct
21 Correct 873 ms 95272 KB Output is correct
22 Correct 903 ms 95280 KB Output is correct
23 Correct 890 ms 95376 KB Output is correct
24 Correct 879 ms 95216 KB Output is correct
25 Correct 891 ms 95276 KB Output is correct
26 Correct 879 ms 95332 KB Output is correct
27 Correct 839 ms 95372 KB Output is correct
28 Correct 847 ms 95308 KB Output is correct
29 Correct 837 ms 95416 KB Output is correct
30 Correct 844 ms 95632 KB Output is correct
31 Correct 857 ms 95836 KB Output is correct
32 Correct 845 ms 96688 KB Output is correct
33 Correct 884 ms 98616 KB Output is correct
34 Correct 881 ms 102032 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 42580 KB Output is correct
2 Correct 20 ms 42672 KB Output is correct
3 Correct 22 ms 42732 KB Output is correct
4 Correct 694 ms 77596 KB Output is correct
5 Correct 739 ms 78532 KB Output is correct
6 Correct 849 ms 89740 KB Output is correct
7 Correct 896 ms 95732 KB Output is correct
8 Correct 903 ms 95812 KB Output is correct
9 Correct 889 ms 95772 KB Output is correct
10 Correct 921 ms 95724 KB Output is correct
11 Correct 896 ms 95696 KB Output is correct
12 Correct 952 ms 95696 KB Output is correct
13 Correct 898 ms 95696 KB Output is correct
14 Correct 89 ms 48552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 42580 KB Output is correct
2 Correct 24 ms 42624 KB Output is correct
3 Correct 20 ms 42660 KB Output is correct
4 Correct 22 ms 42744 KB Output is correct
5 Correct 21 ms 42776 KB Output is correct
6 Correct 21 ms 42680 KB Output is correct
7 Correct 22 ms 42672 KB Output is correct
8 Correct 25 ms 42780 KB Output is correct
9 Correct 23 ms 42816 KB Output is correct
10 Correct 23 ms 42764 KB Output is correct
11 Correct 22 ms 42800 KB Output is correct
12 Correct 22 ms 42708 KB Output is correct
13 Correct 23 ms 42724 KB Output is correct
14 Correct 22 ms 42708 KB Output is correct
15 Correct 22 ms 42848 KB Output is correct
16 Correct 22 ms 42776 KB Output is correct
17 Correct 23 ms 42820 KB Output is correct
18 Correct 21 ms 42748 KB Output is correct
19 Correct 23 ms 42728 KB Output is correct
20 Correct 22 ms 42836 KB Output is correct
21 Correct 25 ms 42768 KB Output is correct
22 Correct 22 ms 42724 KB Output is correct
23 Correct 21 ms 42828 KB Output is correct
24 Correct 26 ms 42712 KB Output is correct
25 Correct 22 ms 42776 KB Output is correct
26 Correct 22 ms 42828 KB Output is correct
27 Correct 22 ms 42580 KB Output is correct
28 Correct 21 ms 42728 KB Output is correct
29 Correct 23 ms 42832 KB Output is correct
30 Correct 28 ms 43348 KB Output is correct
31 Correct 26 ms 43452 KB Output is correct
32 Correct 28 ms 43680 KB Output is correct
33 Correct 29 ms 43660 KB Output is correct
34 Correct 29 ms 43604 KB Output is correct
35 Correct 28 ms 43604 KB Output is correct
36 Correct 29 ms 43612 KB Output is correct
37 Correct 29 ms 43664 KB Output is correct
38 Correct 28 ms 43900 KB Output is correct
39 Correct 28 ms 43908 KB Output is correct
40 Correct 32 ms 44056 KB Output is correct
41 Correct 28 ms 43804 KB Output is correct
42 Correct 28 ms 43836 KB Output is correct
43 Correct 28 ms 43860 KB Output is correct
44 Correct 34 ms 43756 KB Output is correct
45 Correct 28 ms 43772 KB Output is correct
46 Correct 27 ms 43716 KB Output is correct
47 Correct 28 ms 43732 KB Output is correct
48 Correct 28 ms 43684 KB Output is correct
49 Correct 28 ms 43724 KB Output is correct
50 Correct 26 ms 43560 KB Output is correct
51 Correct 26 ms 43592 KB Output is correct
52 Correct 29 ms 43640 KB Output is correct
53 Correct 27 ms 43604 KB Output is correct
54 Correct 27 ms 43660 KB Output is correct
55 Correct 27 ms 43648 KB Output is correct
56 Correct 23 ms 42708 KB Output is correct
57 Correct 22 ms 43376 KB Output is correct
58 Correct 29 ms 43604 KB Output is correct
59 Correct 19 ms 42580 KB Output is correct
60 Correct 20 ms 42580 KB Output is correct
61 Correct 20 ms 42708 KB Output is correct
62 Correct 452 ms 87188 KB Output is correct
63 Correct 327 ms 92184 KB Output is correct
64 Correct 468 ms 101836 KB Output is correct
65 Correct 588 ms 110576 KB Output is correct
66 Correct 586 ms 110484 KB Output is correct
67 Correct 595 ms 110716 KB Output is correct
68 Correct 583 ms 110652 KB Output is correct
69 Correct 581 ms 110596 KB Output is correct
70 Correct 397 ms 101492 KB Output is correct
71 Correct 395 ms 101460 KB Output is correct
72 Correct 392 ms 101428 KB Output is correct
73 Correct 99 ms 88416 KB Output is correct
74 Correct 665 ms 111808 KB Output is correct
75 Correct 103 ms 48548 KB Output is correct
76 Correct 21 ms 42648 KB Output is correct
77 Correct 425 ms 68960 KB Output is correct
78 Correct 722 ms 74356 KB Output is correct
79 Correct 543 ms 75208 KB Output is correct
80 Correct 901 ms 90772 KB Output is correct
81 Correct 888 ms 90928 KB Output is correct
82 Correct 884 ms 90884 KB Output is correct
83 Correct 894 ms 90640 KB Output is correct
84 Correct 918 ms 90904 KB Output is correct
85 Correct 952 ms 91036 KB Output is correct
86 Correct 899 ms 90864 KB Output is correct
87 Correct 940 ms 91240 KB Output is correct
88 Correct 910 ms 91324 KB Output is correct
89 Correct 934 ms 92508 KB Output is correct
90 Correct 926 ms 97436 KB Output is correct
91 Correct 896 ms 91440 KB Output is correct
92 Correct 930 ms 91436 KB Output is correct
93 Correct 923 ms 91340 KB Output is correct
94 Correct 854 ms 95288 KB Output is correct
95 Correct 861 ms 95408 KB Output is correct
96 Correct 873 ms 95272 KB Output is correct
97 Correct 903 ms 95280 KB Output is correct
98 Correct 890 ms 95376 KB Output is correct
99 Correct 879 ms 95216 KB Output is correct
100 Correct 891 ms 95276 KB Output is correct
101 Correct 879 ms 95332 KB Output is correct
102 Correct 839 ms 95372 KB Output is correct
103 Correct 847 ms 95308 KB Output is correct
104 Correct 837 ms 95416 KB Output is correct
105 Correct 844 ms 95632 KB Output is correct
106 Correct 857 ms 95836 KB Output is correct
107 Correct 845 ms 96688 KB Output is correct
108 Correct 884 ms 98616 KB Output is correct
109 Correct 881 ms 102032 KB Output is correct
110 Correct 21 ms 42580 KB Output is correct
111 Correct 20 ms 42672 KB Output is correct
112 Correct 22 ms 42732 KB Output is correct
113 Correct 694 ms 77596 KB Output is correct
114 Correct 739 ms 78532 KB Output is correct
115 Correct 849 ms 89740 KB Output is correct
116 Correct 896 ms 95732 KB Output is correct
117 Correct 903 ms 95812 KB Output is correct
118 Correct 889 ms 95772 KB Output is correct
119 Correct 921 ms 95724 KB Output is correct
120 Correct 896 ms 95696 KB Output is correct
121 Correct 952 ms 95696 KB Output is correct
122 Correct 898 ms 95696 KB Output is correct
123 Correct 89 ms 48552 KB Output is correct
124 Correct 860 ms 92136 KB Output is correct
125 Correct 594 ms 87788 KB Output is correct
126 Correct 997 ms 94340 KB Output is correct
127 Correct 945 ms 94220 KB Output is correct
128 Correct 935 ms 94208 KB Output is correct
129 Correct 933 ms 94280 KB Output is correct
130 Correct 926 ms 94152 KB Output is correct
131 Correct 726 ms 109492 KB Output is correct
132 Correct 766 ms 110644 KB Output is correct
133 Correct 760 ms 109468 KB Output is correct
134 Correct 876 ms 98872 KB Output is correct
135 Correct 866 ms 98864 KB Output is correct
136 Correct 886 ms 98880 KB Output is correct
137 Correct 708 ms 91404 KB Output is correct
138 Correct 681 ms 91384 KB Output is correct
139 Correct 667 ms 91420 KB Output is correct
140 Correct 682 ms 91592 KB Output is correct
141 Correct 672 ms 91468 KB Output is correct
142 Correct 704 ms 91460 KB Output is correct
143 Correct 113 ms 80880 KB Output is correct
144 Correct 959 ms 95464 KB Output is correct