第39680题 单选题
下列代码是一维数组优化 0/1 背包的核心片段,执行后 dp[8] 的输出结果是( )。
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int w = 3, v = 5, W = 8;
    int dp[9] = {0};
    for (int c = W; c >= w; c--)
        dp[c] = max(dp[c], dp[c - w] + v);
    cout << dp[8] << endl;
    return 0;
}
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
知识点:
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析