1013 - #include<iostream>...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: #include<iostream> #include<cstring> using namespace std; const int SIZ = 504; const int LEN = 104; int num; int tab[2][SIZ][SIZ]; int (*cur)[SIZ]; int (*nex)[SIZ]; int (*tmp)[SIZ]; int wei[LEN], siz[LEN]; int w[3], s[3], d[3]; int cnt[4]; int getVal(int x, int y, int z){ int r = x*d[0] + y*d[1] + z*d[2]; int t = min(x/cnt[0], y/cnt[1]); t = min(t, z/cnt[2]); t = t * cnt[3] + (x-t*cnt[0])*d[0] + (y-t*cnt[1])*d[1] + (z-t*cnt[2])*d[2]; r = max(r, t); return r; } void fun(){ memset(tab, -1, sizeof(tab)); tab[0][0][0] = 0; cur = tab[0]; nex = tab[1]; int x, y, a, b; for (int i=1; i<=num; ++i){ memset(nex, -1, sizeof(tab[0])); int ma = min(wei[i]/w[0], siz[i]/s[0]); for (x=0; x<=500; ++x){ for (y=0; y<=500; ++y){ if (cur[x][y] < 0) continue; for (int a=0; a<=ma && a+x<=500; ++a){ int mb = min((wei[i]-w[0]*a)/w[1], (siz[i]-s[0]*a)/s[1]); for (int b=0; b<=mb&&b+y<=500; ++b){ int v = min((wei[i]-w[0]*a-w[1]*b)/w[2], (siz[i]-s[0]*a- s[1]*b)/s[2]); v += cur[x][y]; if (nex[x+a][y+b] < v){ nex[x+a][y+b] = v;...
View Full Document

Page1 / 3

1013 - #include<iostream>...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online