为什么为TLE一个点。。。。。1.03s
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll w[20000005], v[20000005], dp[2005];
ll m, n, x, y, z, cnt;
ll read() {
ll x = 0;
char ch = getchar();
while (!isdigit(ch)) ch = getchar();
while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
return x;
}
int main() {
m = read();
n = read();
for (ll i = 1; i <= n; ++i) {
x = read(), y = read(), z = read();
for (ll j = 1; j <= z; j <<= 1) {
v[++cnt] = j*x;
w[cnt] = j*y;
z -= j;
}
if (z) {
v[++cnt] = z*x;
w[cnt] = z*y;
}
}
for (ll i = 1; i <= cnt; ++i)
for (ll j = m; j >= w[i]; --j)
dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
cout << dp[m];
return 0;
}