摘要:
//设正整数值为x,那么负整数绝对值为sum - x //target = x - (sum - x) //x = (target + sum) / 2 const int N = 1010; class Solution { public: int dp[N]; int findTargetSum 阅读全文
posted @ 2022-09-13 15:13
hjy94wo
阅读(11)
评论(0)
推荐(0)
摘要:
const int N = 3010; class Solution { public: int dp[N]; int lastStoneWeightII(vector<int>& stones) { int sum = 0; for (int i = 0; i < stones.size(); i 阅读全文
posted @ 2022-09-13 14:45
hjy94wo
阅读(18)
评论(0)
推荐(0)
摘要:
背包问题 01背包 (1). 二维dp #include<iostream> using namespace std; const int N = 1010; int m, n; int V[N], W[N]; int f[N][N]; //f[i][j]表示从i个物品中选,容量不超过j的最大价值 阅读全文
posted @ 2022-09-13 14:44
hjy94wo
阅读(32)
评论(0)
推荐(0)
摘要:
01背包 const int N = 20010; class Solution { public: int dp[N]; bool canPartition(vector<int>& nums) { int sum = 0; for (int i = 0; i < nums.size(); i + 阅读全文
posted @ 2022-09-13 10:52
hjy94wo
阅读(14)
评论(0)
推荐(0)