#1886
Rucsac1
Într-un magazin sunt n
obiecte; pentru fiecare se cunoaște greutatea G
și valoarea V
. Un hoț intră în magazin având un rucsac ce poate transporta o greutate maximă GMax
. El va fura anumite obiecte, astfel încât suma greutăților obiectelor furate să nu depășească GMax
.
Să se stabilească câștigul maxim pe care îl poate obține hoțul. Câștigul este egal cu suma valorilor obiectelor furate.
Problema | Rucsac1 | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #48516543 | Utilizator | |
Fișier | rucsac1.cpp | Dimensiune | 615 B |
Data încărcării | 28 Ianuarie 2024, 14:33 | Scor / rezultat | Eroare de compilare |
rucsac1.cpp:4:12: error: array bound is not an integer constant before ']' token int gr[Vmax],c[Vmax],best[Vmax][10*Vmax]; ^ rucsac1.cpp:4:20: error: array bound is not an integer constant before ']' token int gr[Vmax],c[Vmax],best[Vmax][10*Vmax]; ^ rucsac1.cpp:4:31: error: array bound is not an integer constant before ']' token int gr[Vmax],c[Vmax],best[Vmax][10*Vmax]; ^ rucsac1.cpp:4:36: error: invalid operands of types 'int' and 'int [1000][1000]' to binary 'operator*' int gr[Vmax],c[Vmax],best[Vmax][10*Vmax]; ^ rucsac1.cpp: In function 'int main()': rucsac1.cpp:10:18: error: cannot bind 'std::istream {aka std::basic_istream<char>}' lvalue to 'std::basic_istream<char>&&' cin>>gr[i]>>c[i]; ^ In file included from /usr/include/c++/4.8/sstream:38:0, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from rucsac1.cpp:1: /usr/include/c++/4.8/istream:872:5: error: initializing argument 1 of 'std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&&, _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = int [1000]]' operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x) ^ rucsac1.cpp:13:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] if(gr[i]<=j) ^ rucsac1.cpp:14:36: error: invalid operands of types 'int' and 'int [1000]' to binary 'operator-' if(best[i-1][j-gr[i]]+c[i]>best[i-1][j]) ^ rucsac1.cpp:15:48: error: invalid operands of types 'int' and 'int [1000]' to binary 'operator-' best[i][j]=best[i-1][j-gr[i]]+c[i]; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Rucsac1 face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:
Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.