裸的。
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn = 55, maxm = 1005;
int n, m, dp[maxm], c[maxn], w[maxn];
inline int iread() {
int f = 1, x = 0; char ch = getchar();
for(; ch < '0' || ch > '9'; ch = getchar()) f = ch == '-' ? -1 : 1;
for(; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
return f * x;
}
int main() {
int T = iread();
while(T--) {
for(int i = 0; i < maxm; i++) dp[i] = 0;
for(int i = 0; i < maxn; i++) c[i] = w[i] = 0;
m = iread(); n = iread();
for(int i = 1; i <= n; i++) c[i] = iread(), w[i] = iread();
dp[0] = 0;
for(int i = 1; i <= n; i++) for(int j = m; j >= c[i]; j--) dp[j] = max(dp[j], dp[j - c[i]] + w[i]);
printf("Hey stupid robber, you can get %d.\n", dp[m]);
}
return 0;
}