Cod sursa(job #3127193)
Utilizator | Data | 7 mai 2023 13:20:46 | |
---|---|---|---|
Problema | Problema rucsacului | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.18 kb |
#import<fstream>
std::ifstream f("rucsac.in");int N,G,a[1<<14],W,P,i;main(){f>>N>>G;while(f>>W>>P)for(i=G;i>=W;i--)a[i]=std::max(a[i],a[i-W]+P);std::ofstream("rucsac.out")<<a[G];}