Cod sursa(job #1686681)
Utilizator | Data | 12 aprilie 2016 12:56:06 | |
---|---|---|---|
Problema | Problema rucsacului | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.2 kb |
#include <fstream>
using namespace std;ifstream f("rucsac.in");ofstream g("rucsac.out");int n,G,w,p,v[10002];int main(){f>>n>>G;while(n--){f>>w>>p;for(int j=G;j>=w;j--)v[j]=max(v[j],v[j-w]+p);}g<<v[G];}