OJ-Problems-Source/CodeVS/2837_冰封.c

28 lines
491 B
C
Raw Normal View History

2016-07-06 14:28:18 +08:00
/*
:
:p2837
*/
#include <stdio.h>
#include <string.h>
const int size = 0xfffff;
int n, m;
int h[size], v[size], dp[size];
int max(int x, int y){
return x > y ? x : y;
}
int main(){
scanf("%d%d", &n, &m);
for(int i = 0; i < n; i++){
scanf("%d%d", &h[i], &v[i]);
}
for(int i = 0; i < n; i++)
for(int j = m; j >= h[i]; j--)
dp[j] = max(dp[j], dp[j - h[i]] + v[i]);
printf("%d\n", dp[m]);
return 0;
}