- The document contains code and explanations for solving optimization problems using dynamic programming, including calculating minimum costs using a 2D array to store results.
- It describes applying dynamic programming to problems involving finding minimum costs for tasks that can be split into subtasks, with the overall cost determined by combining subtask costs.
- The code provided shows initializing a 2D array and using nested for loops to iterate through values, calculate minimum costs based on previous results, and store them in the 2D array to build up an optimal solution.
2. 2
?? E F Lh ¡° 1 O ih
?? j E F O r
??
¨C? E 0+ 12. / F E 0+ 12. / F
3. 51
?? ¡° 1 j s s h
?? ¡° 1 a a ¡°j D C Oh
?? O ¡° 1 j r r h
?? ok
¨C? sr at
?? Tc c
?? a?¡¯ j ?¡® V S T
¨C? 5 : A 5 5A A 5 : 4
¨C? ¡° a Ot
?? Tc c
?? I ? ? ¡° _? a p n V S T
?? Lh ata?¡¯ j ?¡® had Ve
5. =A
?? ?2 ? ?+ ? E
?? ? ? ?5 ? ?2 ? D
?? ? [
5 ?+ ?5 ? L ?5 ?VO A
VCD D
?? 2 ? ?5 ? VT C AV ]
?? VT C A P
??
¨C? ? ?2 ? ?
¨C? ? ?+ ? ?
¨C? E[ ? ? E C
9. ?? 2 E 9 9i T 9
L T N I ETF
?? S 5 N F9 T
V V V D
?? N I E V ? N
??
¨C? 2
¨C? 5
¨C?
10. ??
¨C? i T O E 5 V
??
¨C? L O V 9
i T L
??
¨C? E 9 E 5 BV T S
¨C? N O F9 O i TTF
¨C? 9<2 ? O =E B V
??
¨C? < = S
?? S D S
11. ??
¨C? B LI L
¨C? I F95 V V ? L
¨C? < L=D <i T = BO F 9DD
E ¨C L
?? B
??
¨C? ? E < L=D <i T = BS
¨C? DD E 5 BV A B BO F9
BO i TTF
?? DD 9 SCF9 BO
F 9 ? S
¨C? <2 BO =E B V
13. ?? [
?? r ND r D
?? rR SmR
S[
?? R S rT
?? R S r r o
?? o]m T [ ag
o l rO
??
¨C? ( V V ( ,
¨C? ( V V ( + j V
14. ??
¨C? ( V V V (
??
¨C? [ j
?? r r o lN g r
?? r o lN r D x o mo
?? i ND [ N D x o
¨C? j
?? D D A m ag N
Xo X [
?? j N r D ? ) ) mo
15. ??
¨C? 2 DA EA D ll E l
MMMMMm
¨C? X
??
¨C? 9 ? )
DP[][]% %INF%l %
DP[0][0]%=%0%
for%(i%:%1...M)%for%(j%:%0...X[i]71)%
%%for%(k%:%X[i]...N)%
%%%%L%=%X[i]7j%
%%%%R%=%k7X[i]%
%%%%T%=%min(L*2+R,%L+R*2)%
%%%%DP[i][k]%=%min(DP[i][k],%max(DP[i71][j],%T))%