被虐爆了。。。而且是这种半年前刷过的题目。。。
算法是合并两个有序的序列,其他的方程之类与单人背包其实差不多。
Code :
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define swap(a, b, t) ({t _ = (a); (a) = (b); (b) = _;})
#define max(a, b) ({int _ = (a), __ = (b); _ > __ ? _ : __;})
#define min(a, b) ({int _ = (a), __ = (b); _ < __ ? _ : __;})
#define maxk 55
#define maxn 205
#define maxv 5005
int k, m, n, ans;
int v[maxn], w[maxn];
struct arr{
int a[maxk];
int & len() {return a[0];}
int & operator [](int b) {return a[b];}
} f[maxv];
arr get(arr & a, arr & b, int w)
{
arr c = arr();
c.len() = min(k, a.len() + b.len());
for (int i = 1,p = 1, q = 1; i <= c.l