Jesse has broken into a sporting goods store to steal some training equipment. He can only carry out a certain amount of stuff before it gets too heavy. In addition, Jesse can only make one trip in and out of the store before the cops arrive, so he wants to be sure to get the most value out of the stuff he takes. Input for the program will be as below. The first line will contain how much Jesse can carry. This line is followed by a single item per line. Each of these lines will contain the name of the item, the number of items available, each individual item’s weight and its value. There will be up to 10 different items. Output the number of each item type he should take to maximize his value as well as the max value.

icon
Related questions
Question
C++
Jesse the Body-Building Burglar

Jesse has broken into a sporting goods store to steal some training equipment. He can only carry out a certain amount of stuff before it gets too heavy. In addition, Jesse can only make one trip in and out of the store before the cops arrive, so he wants to be sure to get the most value out of the stuff he takes. Input for the program will be as below. The first line will contain how much Jesse can carry. This line is followed by a single item per line. Each of these lines will contain the name of the item, the number of items available, each individual item’s weight and its value. There will be up to 10 different items. Output the number of each item type he should take to maximize his value as well as the max value.
 
Example File:
100
Barbell 1 25 10
Plate 4 40 12
Ball 5 30 15
Rope 10 5 10
Bench 1 50 20
Output:

10 Rope, 1 Bench 120

Attached file is the JBB dynamic programming
6
M18
7
4
1
2 Plate
3 Ball
4 Rope
5 Bench
19
8
0
9
2
10
10
11
"
12
13
14
16
17
19
2
JBB -Dynamic Programming.xlsx [Protected View] - Excel
Tell me what you want to do...
Home Insert Page Layout Formulas Data Review View
PROTECTED VIEW Be careful-files from the Internet can contain viruses. Unless you need to edit, it's safer to stay in Protected View.
41
File
43
44
45
A
Barbell
Ready
B
1
4
5
10
1
34°F
Clear
C
I
25
40
30
5
50
Sheet1
D
10
12
15
10
20
E
F
fx
G
0
0
1
2
2
3
4
3
5
3
6
19
7
8
5
9
7
10
11
**
12
7
13
14
15
16
17
18
19
20
21
H
weight
value
0
0
0
U
0
0
n
U
n
9
n
0
n
0
J
0
=
0
=
0
=
0
=
0
X
0
X
0
X
0
X
0
0
0
0
0
I
1
Barbell Plate
25
10
1
0
0
0
0
9
0
V
0
9
0
9
0
9
0
0
=
0
=
0
=
0
=
0
=
0
=
0
=
0
=
0
0
0
0
0
J
▬
2
40
12
2
0
0
0
0
9
0
9
n
9
0
n
0
=
0
=
0
=
0
=
0
=
0
=
0
=
0
=
0
=
0
0
0
0
0
K
Plate
3
Plate
40
12
3
0
n
0
0
0
0
0
0
0
0
4
40
12
4
0
U
0
0
0
0
V
0
V
0
V
0
0
0
0
0
d
d
0
0
0
0
0
0
0
M
Plate
Search
5
40
12
5
0
0
0
9
0
9
0
9
0
9
0
9
O
U
0
=
16
10
10
10
10
10
7
10
7
10
10
10
10
10
N
Ball
6
30
15
6
0
0
O
0
9
9
O
9
O
0
U
0
=
0
=
0
10
10
10
10
0
Ball
Ball
30
15
7
0
O
0
9
0
9
O
9
O
9
n
9
n
U
0
10
10
10
P
10
10
10
10
10
10
8
30
15
8
0
0
0
0
9
0
19
0
19
0
19
9
0
0
=
0
=
0
10
10
10
10
Q
Ball
9
30
15
0
O
0
9
0
9
O
9
9
n
9
n
U
0
10
10
10
10
10
10
10
10
10
10
10
R
Ball
10
30
15
10
0
0
0
2
0
2
0
2
0
V
0
2
0
0
0
0
10
=
20
=
20
=
20
=
20
=
20
=
20
20
20
20
20
S
11
10
11
0
0
U
0
0
V
0
V
16
Rope Rope Rope Rope Rope Rope Rope Rope Rope
5
5
5
5
5
5
0
9
0
9
0
U
0
=
0
=
0
10
20
20
M
20
=
T
20
=
20
20
20
20
20
20
12
10
12
0
0
n
0
9
0
9
0
9
0
n
0
=
0
=
0
U
20
20
20
20
Enable Editing
13
5
10
13
0
0
0
n
0
0
10
20
20
20
=
=
20
20
20
20
20
I ◄
14
10
14
0
0
U
0
V
0
V
0
V
0
V
0
0
0
0
0
=
J
10
20
20
20
20
20
20
20
20
20
20
15
5
10
15
0
0
O
9
n
V
0
V
0
9
n
0
0
H
0
=
0
=
10
=
20
2
30
30
2
30
2
X
30
2
30
30
30
30
30
10
16
0
0
U
0
0
0
V
0
V
0
V
0
0
0
0
Y
=
J
ent
10
20
30
30
30
30
30
30
30
30
30
17
10
17
0
0
0
9
0
0
0
9
n
9
0
0
0
=
0
=
10
=
20
2
30
*
30
30
30
30
30
30
30
30
7
X
18
10
18
0
n
O
9
0
9
O
9
O
9
O
0
U
0
H
0
=
0
AA
30
30
30
19
5
10
19
0
0
0
9
0
V
O
9
9
n
9
n
U
0
10
20
30
30
30
30
30
30
30
30
30
AB
20
Rope Bench
5
10
20
0
0
0
0
2
0
2
0
2
0
2
0
0
10
=
20
=
30
*
40
=
AC
21
40
40
40
40
40
40
50
20
21
0
0
0
0
9
0
V
0
9
0
9
0
U
0
=
0
=
0
7
10
20
30
=
40
40
40
40
40
40
40
40
#
AD
22
0
0
0
0
9
n
9
n
0
n
0
=
0
=
0
40
40
40
K
AE
23
0
0
n
n
n
9
0
9
0
9
0
9
0
10
20
30
40
=
40
=
40
=
40
40
40
40
40
AF
I
24
0
0
0
U
0
U
0
9
n
0
n
0
0
=
0
40
40
AG
25
0
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
2
=
*
*
50
50
50
50
50
50
50
4
AH
Share
26
0
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
M
2
7
40
50
50
50
50
50
50
50
X
7:06 PM
11/20/2023
A
X
▶
+ 56%
Transcribed Image Text:6 M18 7 4 1 2 Plate 3 Ball 4 Rope 5 Bench 19 8 0 9 2 10 10 11 " 12 13 14 16 17 19 2 JBB -Dynamic Programming.xlsx [Protected View] - Excel Tell me what you want to do... Home Insert Page Layout Formulas Data Review View PROTECTED VIEW Be careful-files from the Internet can contain viruses. Unless you need to edit, it's safer to stay in Protected View. 41 File 43 44 45 A Barbell Ready B 1 4 5 10 1 34°F Clear C I 25 40 30 5 50 Sheet1 D 10 12 15 10 20 E F fx G 0 0 1 2 2 3 4 3 5 3 6 19 7 8 5 9 7 10 11 ** 12 7 13 14 15 16 17 18 19 20 21 H weight value 0 0 0 U 0 0 n U n 9 n 0 n 0 J 0 = 0 = 0 = 0 = 0 X 0 X 0 X 0 X 0 0 0 0 0 I 1 Barbell Plate 25 10 1 0 0 0 0 9 0 V 0 9 0 9 0 9 0 0 = 0 = 0 = 0 = 0 = 0 = 0 = 0 = 0 0 0 0 0 J ▬ 2 40 12 2 0 0 0 0 9 0 9 n 9 0 n 0 = 0 = 0 = 0 = 0 = 0 = 0 = 0 = 0 = 0 0 0 0 0 K Plate 3 Plate 40 12 3 0 n 0 0 0 0 0 0 0 0 4 40 12 4 0 U 0 0 0 0 V 0 V 0 V 0 0 0 0 0 d d 0 0 0 0 0 0 0 M Plate Search 5 40 12 5 0 0 0 9 0 9 0 9 0 9 0 9 O U 0 = 16 10 10 10 10 10 7 10 7 10 10 10 10 10 N Ball 6 30 15 6 0 0 O 0 9 9 O 9 O 0 U 0 = 0 = 0 10 10 10 10 0 Ball Ball 30 15 7 0 O 0 9 0 9 O 9 O 9 n 9 n U 0 10 10 10 P 10 10 10 10 10 10 8 30 15 8 0 0 0 0 9 0 19 0 19 0 19 9 0 0 = 0 = 0 10 10 10 10 Q Ball 9 30 15 0 O 0 9 0 9 O 9 9 n 9 n U 0 10 10 10 10 10 10 10 10 10 10 10 R Ball 10 30 15 10 0 0 0 2 0 2 0 2 0 V 0 2 0 0 0 0 10 = 20 = 20 = 20 = 20 = 20 = 20 20 20 20 20 S 11 10 11 0 0 U 0 0 V 0 V 16 Rope Rope Rope Rope Rope Rope Rope Rope Rope 5 5 5 5 5 5 0 9 0 9 0 U 0 = 0 = 0 10 20 20 M 20 = T 20 = 20 20 20 20 20 20 12 10 12 0 0 n 0 9 0 9 0 9 0 n 0 = 0 = 0 U 20 20 20 20 Enable Editing 13 5 10 13 0 0 0 n 0 0 10 20 20 20 = = 20 20 20 20 20 I ◄ 14 10 14 0 0 U 0 V 0 V 0 V 0 V 0 0 0 0 0 = J 10 20 20 20 20 20 20 20 20 20 20 15 5 10 15 0 0 O 9 n V 0 V 0 9 n 0 0 H 0 = 0 = 10 = 20 2 30 30 2 30 2 X 30 2 30 30 30 30 30 10 16 0 0 U 0 0 0 V 0 V 0 V 0 0 0 0 Y = J ent 10 20 30 30 30 30 30 30 30 30 30 17 10 17 0 0 0 9 0 0 0 9 n 9 0 0 0 = 0 = 10 = 20 2 30 * 30 30 30 30 30 30 30 30 7 X 18 10 18 0 n O 9 0 9 O 9 O 9 O 0 U 0 H 0 = 0 AA 30 30 30 19 5 10 19 0 0 0 9 0 V O 9 9 n 9 n U 0 10 20 30 30 30 30 30 30 30 30 30 AB 20 Rope Bench 5 10 20 0 0 0 0 2 0 2 0 2 0 2 0 0 10 = 20 = 30 * 40 = AC 21 40 40 40 40 40 40 50 20 21 0 0 0 0 9 0 V 0 9 0 9 0 U 0 = 0 = 0 7 10 20 30 = 40 40 40 40 40 40 40 40 # AD 22 0 0 0 0 9 n 9 n 0 n 0 = 0 = 0 40 40 40 K AE 23 0 0 n n n 9 0 9 0 9 0 9 0 10 20 30 40 = 40 = 40 = 40 40 40 40 40 AF I 24 0 0 0 U 0 U 0 9 n 0 n 0 0 = 0 40 40 AG 25 0 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 2 = * * 50 50 50 50 50 50 50 4 AH Share 26 0 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 M 2 7 40 50 50 50 50 50 50 50 X 7:06 PM 11/20/2023 A X ▶ + 56%
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer