Cod sursa(job #1642968)

Utilizator Radu_FilipescuFilipescu Radu Radu_Filipescu Data 9 martie 2016 17:01:10
Problema Problema rucsacului Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.44 kb
#include <fstream>
#include <algorithm>

using namespace std;

ifstream fin("rucsac.in");
ofstream fout("rucsac.out");

int n,g,p[5005],w[5005],a[10005],b[10005];

int main()
{
    int i,j;

    fin>>n>>g;
    for(i=1; i<=n; i++) fin>>w[i]>>p[i];

    for(i=1; i<=n; i++)
       { for(j=1; j<=g; j++)
           if(w[i]>j) a[j]=b[j];
           else a[j]=max(b[j],b[j-w[i]]+p[i]);
         for(j=1;j<=g;j++)


    return 0;
}