ARC 206

https://atcoder.jp/contests/arc206

A. Range Replace

https://atcoder.jp/contests/arc206/tasks/arc206_a

B. Slime Swap

https://atcoder.jp/contests/arc206/tasks/arc206_b

解説 AC

void solve() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N;
    cin >> N;
    vll P(N), C(N);
    rep(i, N) {
        cin >> P[i];
    }
    rep(i, N) {
        cin >> C[i];
        C[i]--;
    }

    vvint cs(N);
    rep(i, N) {
        cs[C[i]].push_back(P[i]);
    }

    auto cal = [&](ll c) -> ll {
        ll sz = cs[c].size();

        ll inf = 1ll << 60;
        vll dp(sz, inf);
        for (ll x : cs[c]) {
            auto it = upper_bound(all(dp), x);
            *it = x;
        }

        ll id = lower_bound(all(dp), inf) - dp.begin();
        return (sz - id) * (c + 1);
    };

    ll ans = 0;
    rep(i, N) ans += cal(i);
    cout << ans << endl;
}

C. Tree Sequence

https://atcoder.jp/contests/arc206/tasks/arc206_c

D. LIS ∩ LDS

https://atcoder.jp/contests/arc206/tasks/arc206_d

E. Rectangle Coloring

https://atcoder.jp/contests/arc206/tasks/arc206_e