Comments

Why is this code https://mirror.codeforces.com/contest/1543/submission/121641823 fast? Shouldn't it get TLE? Are tests bad?

Just erase the second overloading

You need to use dynamic programming with profile.

+7

I hate problem B