第一题用0-1背包的思想,但是一直只能过64% ,好想知道为什么#include#include#include using namespace std;bool isValid (vector& weight, int bagSize, int q) { int len = weight.size(); vector> dp(len + 1, vector(bagSize + 1, false)); dp[0][0] = true; bool flag = false; for (int i = 1; i for (int j = 0; j if (j else if (j == weight[i-1]) dp[i][j] = true; else if (weight[i-1] = j) dp[i][j] = true; else dp[i][j] = dp[i-1][j - weight[i-1]]; if (j == bagSize && dp[i][j]) return true; } } return dp[len][bagSize];}int main(void) { int t; cin >> t; while (t--) { int bagSize, n, q; cin >> bagSize >> n >> q; vector weight(n); for (int i = 0; i > weight[i]; if (isValid(weight, bagSize, q)) cout else cout }}