Pagini recente » Istoria paginii utilizator/hellohowareyou | Cod sursa (job #2479544) | Statistici N/A (fakeacc) | Istoria paginii utilizator/hellohowareyou | Cod sursa (job #1669964)
#include <cstdio>
using namespace std;
inline int max(int a, int b)
{
if (a > b)
return a;
return b;
}
const int SIZE = 10005;
int n, G, w, p, ans, i;
int D[SIZE];
int main()
{
freopen("input.in", "r", stdin);
freopen("output.out", "w", stdout);
scanf("%d %d", &n, &G);
for ( ; n; --n) {
scanf("%d %d", &w, &p);
for (i = G - w; i >= 0; --i)
D[i+w] = max(D[i+w], D[i] + p);
}
for (i = 0; i <= G; ++i)
ans = max(ans, D[i]);
printf("%d\n", ans);
return 0;
}