include [HTML_REMOVED]
include [HTML_REMOVED]
int max(int a, int b) {
return a > b ? a : b;
}
int main() {
int N, V;
scanf(“%d %d”, &N, &V);
int v[N+1], w[N+1];
for(int i = 1; i <= N; i++) {
scanf(“%d %d”, &v[i], &w[i]);
}
int dp[N+1][V+1];
memset(dp, 0, sizeof(dp));
for(int i = 1; i <= N; i++) {
for(int j = 0; j <= V; j++) {
if(j < v[i]) {
dp[i][j] = dp[i-1][j];
} else {
dp[i][j] = max(dp[i-1][j], dp[i-1][j-v[i]] + w[i]);
}
}
}
int max_value = 0;
for(int i = 0; i <= V; i++) {
max_value = max(max_value, dp[N][i]);
}
printf("%d\n", max_value);
return 0;
}
好厉害