Problem 750
Optimal Card Stacking
Card Stacking is a game on a computer starting with an array of
A stack of cards can be moved by dragging horizontally with the mouse to another stack but only when the resulting stack is in sequence. The goal of the game is to combine the cards into a single stack using minimal total drag distance.
For the given arrangement of
For
We define
For example, when
You are given
Find
Note:
最优卡牌堆叠
卡牌堆叠是一款电脑游戏,初始状态为
对如上图所示的
对于
记
例如,当
已知
求
注:并非所有的
Gitalking ...