#include #include using namespace std; struct a_t { int c, v; }; vector a; vector > memo; int max(int a, int b) { if(a>b) return a; return b; } int max_u(int& m, int v) { if(m=a[n-1].c) max_u(ret, solve_r(t-a[n-1].c, v+a[n-1].v, n-1)); return memo[n][t]=ret; } int solve(int t) { memo.clear(); memo.resize(a.size()+1); for(int i=memo.size()-1;i>=0;i--) { memo[i].resize(t+1, -1); } return solve_r(t, 0, a.size()); } int main(void) { int t, n, i, j; vector c, v, f; while(scanf("%d%d", &t, &n)==2) { a.clear(); c.resize(n); v.resize(n); for(i=0;i>j;j++) { a.push_back((a_t){c[i], v[i]>>j}); } } /* for(i=0;i