Last active
April 18, 2026 09:08
-
-
Save thinkphp/cb77914cb010279008f42583a6fbfda5 to your computer and use it in GitHub Desktop.
input pentru problema rucsacului
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| input: | |
| numar de obiecte, capacitate rucsac | |
| urmatoarele linii: | |
| greutate obiecte, profit obiect | |
| 5 10 | |
| 3 2 | |
| 4 3 | |
| 3 8 | |
| 10 12 | |
| 5 7 | |
| Output: Matricea costurilor, profitul si obiectele alese | |
| Tabel Castig (DP): | |
| 0 1 2 3 4 5 6 7 8 9 10 | |
| i=0 0 0 0 0 0 0 0 0 0 0 0 | |
| i=1 0 0 0 2 2 2 2 2 2 2 2 | |
| i=2 0 0 0 2 3 3 3 5 5 5 5 | |
| i=3 0 0 0 8 8 8 10 11 11 11 13 | |
| i=4 0 0 0 8 8 8 10 11 11 11 13 | |
| i=5 0 0 0 8 8 8 10 11 15 15 15 | |
| Profit maxim: 15 | |
| Obiecte alese: 3 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment