跟风,阿pu,一起奔~# pets - 心有所宠
j*2
1 楼
每次跳到能跳的最远,结果就是最小步数吗?这个是个greedy吧,能讨论下怎么证明吗
?实在是个新手。
greedy algorithm:
starting at position i, jumping step j, the size of jump j is the one that
achieves max reach from step j-1 to step j.
Proof:
(1) step j is also the max reach from step 0 to step j.
(2) if there exists another strategy that results in fewer total steps, then
there must exist a step (step K1) that covers entirely a step (step K2) in
the greedy strategy. Namely, step K1's start <=step K2's start && step K1's
end>step K2's end. It contradicts the fact that step K2's end is the max
reach from all steps before it.
?实在是个新手。
greedy algorithm:
starting at position i, jumping step j, the size of jump j is the one that
achieves max reach from step j-1 to step j.
Proof:
(1) step j is also the max reach from step 0 to step j.
(2) if there exists another strategy that results in fewer total steps, then
there must exist a step (step K1) that covers entirely a step (step K2) in
the greedy strategy. Namely, step K1's start <=step K2's start && step K1's
end>step K2's end. It contradicts the fact that step K2's end is the max
reach from all steps before it.