题目链接:​​传送门​

说不出是简单还是难
只是有点显然
f[i][j]表示跳到第i步跳了j次的最大得分
如果第i步跳了f[i][j]=f[i-1][j-1]+S[i]
没跳就是f[i][j]=f[i-1][j]-S[i]
如果现在跳了T的倍数步
那么可以加上B的贡献f[i][j]=f[i-1][j-1]+S[i]+B[i]
就这样
但这样样例还过不了为40
答案-1去交了一发WA 0
问题是没有考虑一直不跳的情况
不然算出的答案会不符合条件

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <algorithm>
#include <climits>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define
#define

using namespace std;
typedef long long ll;
int n, T, a[A], b[A], f[A][A], ans;

int main(int argc, char const *argv[]) {
cin >> n >> T;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++) cin >> b[i];
for (int i = 1; i <= n; i++) f[i][0] = f[i - 1][0] - a[i];
for (int i = 1; i <= n; i++)
for (int j = 1; j <= i; j++) {
f[i][j] = max(f[i - 1][j] - a[i], f[i - 1][j - 1] + a[i]);
if (j % T == 0) f[i][j] = max(f[i - 1][j - 1] + a[i] + b[i], f[i][j]);
}
for (int i = 1; i <= n; i++) ans = max(ans, f[n][i]);
cout << ans << endl;
}