正文
增加 44 行删除 0 行
302 行未改动全部展开30330430530630730830931031152 行未改动364365366367368369370371294 行未改动全部展开302 行未改动全部展开cout << ans << '\n';return 0;}```---### 六、部分分收割策略52 行未改动---### 四、动态规划思路($O(NM)$)#### 4.1 定义 DP 状态设 $dp[i][j]$ 表示**完成前 $j$ 个步骤,且第 $j$ 个步骤由小组 $i$ 完成时,所用的最少天数**。294 行未改动全部展开302 行未改动全部展开30330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335452 行未改动407408409410411412413414415294 行未改动全部展开302 行未改动全部展开cout << ans << '\n';return 0;}```ect.下标从`1`开始```cpp#include <iostream>#include <algorithm>using namespace std;const int MAXN = 10005;const int MAXM = 105;const long long INF = 1e18;int a[MAXM];int b[MAXN];long long dp[MAXN];int main() {ios::sync_with_stdio(false);cin.tie(nullptr);int N, M;cin >> N >> M;for (int i = 1; i <= M; ++i) cin >> a[i];for (int i = 1; i <= N; ++i) cin >> b[i];// 初始化for (int i = 1; i <= N; ++i) dp[i] = -INF;dp[1] = 0;long long ans = -INF;for (int x = 1; x <= N; ++x) {if (dp[x] == -INF) continue; // 不可达for (int i = 1; i <= M; ++i) {int y = x + a[i];long long score = dp[x] + b[x];if (y > N) {if (score > ans) ans = score;} else {if (score > dp[y]) dp[y] = score;}}}cout << ans << '\n';return 0;}```---### 六、部分分收割策略52 行未改动---### 四、动态规划思路($O(NM)$)**注意行列互换**#### 4.1 定义 DP 状态设 $dp[i][j]$ 表示**完成前 $j$ 个步骤,且第 $j$ 个步骤由小组 $i$ 完成时,所用的最少天数**。294 行未改动全部展开