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