上一页 1 2 3 4 5 6 ··· 8 下一页
摘要: [Algo] 树型dp2 1. 到达首都的最少油耗 // 1. 到达首都的最少油耗 // https://leetcode.cn/problems/minimum-fuel-cost-to-report-to-the-capital/description/ void func1(vector<ve 阅读全文
posted @ 2025-03-22 17:02 yaoguyuan 阅读(8) 评论(0) 推荐(0)
摘要: [Algo] 树型dp 1. 二叉搜索子树的最大键值和 // 1. 二叉搜索子树的最大键值和 // https://leetcode.cn/problems/maximum-sum-bst-in-binary-tree/ struct Info1 { int maxSum; int maxVal; 阅读全文
posted @ 2025-03-22 17:01 yaoguyuan 阅读(6) 评论(0) 推荐(0)
摘要: [Algo] 区间dp2 1. 合唱队 // 1. 合唱队 // https://www.luogu.com.cn/problem/P3205 struct CountStruct { int cntLeft = 0; int cntRight = 0; }; int compute(vector< 阅读全文
posted @ 2025-03-17 12:24 yaoguyuan 阅读(9) 评论(0) 推荐(0)
摘要: [Algo] 区间dp 1. 让字符串成为回文串的最少插入次数 // 1. 让字符串成为回文串的最少插入次数 // https://leetcode.cn/problems/minimum-insertion-steps-to-make-a-string-palindrome/description 阅读全文
posted @ 2025-03-15 18:49 yaoguyuan 阅读(4) 评论(0) 推荐(0)
摘要: [Algo] 多重背包 1. 多重背包 - 二进制分组优化 // 1. 多重背包 - 二进制分组优化 // https://www.luogu.com.cn/problem/P1776 int func(int n, int t, vector<int> &w, vector<int> &v) { 阅读全文
posted @ 2025-03-14 15:00 yaoguyuan 阅读(15) 评论(0) 推荐(0)
摘要: [Algo] 分组背包和完全背包 1. 分组背包模板 // 1. 分组背包模板 // https://www.luogu.com.cn/problem/P1757 int maxValue(vector<vector<int>> &arr, int n, int m) { // arr[i][0] 阅读全文
posted @ 2025-03-13 11:25 yaoguyuan 阅读(14) 评论(0) 推荐(0)
摘要: [Algo] 零一背包 1. 夏季特惠 // 1. 夏季特惠 // https://leetcode.cn/problems/tJau2o/description/ long maxHappyValue(vector<long> &a, vector<long> &b, vector<long> & 阅读全文
posted @ 2025-01-15 14:49 yaoguyuan 阅读(23) 评论(0) 推荐(0)
摘要: [Algo] 子数组最大累加和2 1. 乘积最大子数组 // 1. 乘积最大子数组 // https://leetcode.cn/problems/maximum-product-subarray/ int maxProduct(vector<int>& nums) { int n = nums.s 阅读全文
posted @ 2025-01-13 11:07 yaoguyuan 阅读(13) 评论(0) 推荐(0)
摘要: [Algo] 子数组最大累加和 1. 最大子数组和i // 1. 最大子数组和i // https://leetcode.cn/problems/maximum-subarray/description/ int maxSubArray(vector<int>& nums) { vector<int 阅读全文
posted @ 2025-01-10 13:22 yaoguyuan 阅读(14) 评论(0) 推荐(0)
摘要: [Algo] 三维动态规划 fx1 - 暴力递归, fx2 - 记忆化搜索, fx3 - 严格位置依赖, fx4 - 状态压缩 1. 零和一 // 1. 零和一 // https://leetcode.cn/problems/ones-and-zeroes/ pair<int, int> zeros 阅读全文
posted @ 2025-01-10 13:22 yaoguyuan 阅读(34) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 ··· 8 下一页