Pagini recente » Cod sursa (job #1780244) | Cod sursa (job #651372) | Cod sursa (job #591784) | Cod sursa (job #756680) | Cod sursa (job #1223851)
// Craciun Catalin
// Energii
// Infoarena
#include <iostream>
#include <cstring>
#include <fstream>
struct obj {
int val, weight;
};
using namespace std;
ifstream f("energii.in");
ofstream g("energii.out");
#define GMax 10005
int V[GMax];
int n,weight;
int main() {
f>>n>>weight;
memset(V, 0, sizeof(V));
for (int i=1;i<=n;i++) {
int oVal, oWeight;
f>>oWeight>>oVal;
for (int j=weight; j>=oWeight;j--)
if (V[j-oWeight] + oVal > V[j])
V[j] = V[j-oWeight] + oVal;
}
g<<V[weight]<<'\n';
f.close();
g.close();
return 0;
}