Comments

Thanks for sharing such a thoughtful and helpful book! It is a practical guide for building a CP mindset, developing a strategy, and even living a healthy lifestyle!

Thank you so much! Will there be an api for random problem under certain restrictions?

Thanks for sharing, and I found this really useful! No offense to the authors and developers of themeCP, but actually I created another website for fun, and it's open source. If you would like to use it or contribute, welcome! I will keep the mechanism up-to-date with themeCP. Thanks again.

For F, I feel like we don't need to precompute that much to eliminate cyclic dependencies. Instead, we consider two cases:

  1. ifa[l]==k: we calculatedp1[l][r][k]fromdp1[l+1][r][k] first, then calculatedp2[l][r][kk]fromdp1[l][r][k], where k!=kk.
  2. ifa[l]!=k: we calculatedp2[l][r][k]fromdp2[l+1][r][k] first, then calculatedp1[l][r][k]fromdp2[l][r][k].
My Code
On HelloFromMars → My AtCoder Guest, 3 years ago
0

Hello, bro. Could you try my rating? I think the curve looks wired.

It really doesn't matter. Sublime text is a good choice and many programmers use it. But I go with vim because I love its shortcuts and simplicity.

Excellent concept! Using archives to learn how to solve problems, and learn how to solve fast by participating contests. It helps me a lot, thanks.

It can be easier like this:

    int n, k;
    cin >> n >> k;
    vector<pair<int, int>> a(n);
    for (auto &[x, y] : a) cin >> y >> x;
    sort(a.begin(), a.end());
    multiset<int> S;
    for (int i = 0; i < k; i ++ ) S.insert(0);
    int res = 0;
    for (auto &[y, x] : a)
    {
        auto it = S.upper_bound(x);
        if (it == S.begin()) continue;
        -- it;
        S.erase(it);
        S.insert(y);
        res ++ ;
    }
    cout << res << '\n';

Your answer is very good but I mistakenly voted against, I'm sorry...

Thank you!

Can I use Dijkstra to solve G?

Funny, I received your comment. xD.