Ball 查错
#include <stdio.h>
template<typename Tp>
inline void Read(Tp &x) {
x = 0; int w = 1; char c = getchar();
for (; c < '0' || c > '9'; c = getchar())
if (c == '-') w = -1;
for (; c >= '0' && c <= '9'; c = getchar())
x = (x << 3) + (x << 1) + (c ^ 48);
x *= w;
}
const int N = 105, M = (int)4e4 + 5;
int n, W, nv[N], nw[N], ncnt, f[M];
inline int mx(int p, int q) {return p > q ? p : q;}
int main(void) {
Read(n); Read(W); ncnt = 0;
for (int i = 1, v, w, m; i <= n; ++i) {
Read(v), Read(w), Read(m);
for (int j = 0; (1 << j) <= m; ++j)
nv[++ncnt] = (1 << j) * v, nw[ncnt] = (1 << j) * w, m -= (1 << j);
if (m) nv[++ncnt] = m * v, nw[ncnt] = m * w;
}
for (int i = 1; i <= ncnt; ++i)
for (int j = W; j >= nw[i]; --j)
f[j] = mx(f[j - nw[i]] + nv[i], f[j]);
printf("%d\n", f[W]);
return 0;
}