**Problem:** CSES - Coding Company

**Editorial:** https://usaco.guide/solutions/cses-1665?lang=cpp

I have gone through the above editorial for this problem. The first two transitions make perfect sense, but I don’t understand the last two transitions which are:

- Using i th person to finish an unfinished team.
- Using i to start a new unfinished team.

The problem is with the way the penalties are handled in these two transitions, I don’t understand why it is done that way.

Can anybody please explain these transitions?

[**Note:** I have gone through the Codeforces blog on Non-Trivial DP tricks (“Open And Close Interval”) but that didn’t help.]