摘要:
对序列{a} ,选择m个连续段,求总和最大 O(n^3) const int N=1e3; int a[N],s[N],n,m,f[N][N]; int sum(int i,int j){ return s[j]-s[i-1]; } void solve(){ int i,j,k; for(i=1; 阅读全文
posted @ 2022-10-22 21:56
towboat
阅读(27)
评论(0)
推荐(0)
摘要:
n条线段( 起点,终点,价值,费用) ,选择一些来覆盖 [0,L],注意所选线段不能相交 使价值之和最大? 背包题,而且背包体积要刚好用完 状态第一维放当前的位置(如果放线段编号,emmm好像没法做 f[a[i].y][j]=max(f[a[i].y][j],f[a[i].x][j-a[i].w]+ 阅读全文
posted @ 2022-10-22 16:55
towboat
阅读(20)
评论(0)
推荐(0)
摘要:
f[i] 对于某个区间起点,状态转移到终点,要反过来枚举 i 方程不难想,两种情况 f[i] =max{ f[i+len[j] ] } f[i]= f[i+1]+1 #include <iostream> #include <algorithm> #include <cmath> using nam 阅读全文
posted @ 2022-10-22 13:57
towboat
阅读(19)
评论(0)
推荐(0)
摘要:
很水的区间dp #include <iostream> #include <cstring> #include <cmath> using namespace std ; const int N=502; int n,a[N],f[N][N]; int func(int l,int r){ if(l 阅读全文
posted @ 2022-10-22 12:12
towboat
阅读(11)
评论(0)
推荐(0)