Pagini recente » Cod sursa (job #2184318) | Cod sursa (job #473059) | Cod sursa (job #909845) | Cod sursa (job #881162) | Cod sursa (job #981455)
Cod sursa(job #981455)
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int GMAX = 10003;
int D[GMAX];
int main () {
freopen ("rucsac.in", "r", stdin);
freopen ("rucsac.out", "w", stdout);
int N, G, i, j, a, b, s = 0;
scanf ("%d%d", &N, &G);
for (i = 1; i <= N; ++i) {
scanf ("%d%d", &a, &b);
for (j = G; j >= a; --j)
D[j] = max (D[j], D[j - a] + b);
}
printf ("%d", D[G]);
}