题目:2021 Round-A . K-Goodness String 签到题,计算当前字符串的 K-Goodness Score ,然后与给出的 K 做差即可. #include <iostream> #include <string> using namespace std; int cnt = 1; int solve(const string &s, int n, int k) { int cur = 0; for (int i = 0; i < n / 2;…
对我很有启发的一道题. 这道题的解法中最有思维难度的 observation 是 For simplicity, we will assume that we never eat a stone with zero energy. 求解最优化问题时,我们可以对解空间增加一些限制条件,使解空间更加"规范",同时保证缩小了的解空间中至少包含一个最优解.…