• [1628] Alex’s Game(III)

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • Alex likes to play with one and zero as you know .

    But Alex does’t have a girlfriend now because his girlfriend is trapped in Alcatraz Island.So Alex wants to rescue her.Now Alex has some information about this place.there are two coast(海岸线) which parallel to each otherand there some castles(城堡) in each cosat.Each coast have n(n<=15) castles,each castle has a id which begins from 1.Each castle just has a undirected road with it's adjacent castle .What's more,He must build exactly k bridges between two coast,and the bridge can only be built between two castles which have the same id and the cost is zero.Now Alex is in the first castle in the first coast and his girlfriend is in the last castle in the second coast ,please calculate the shortest distance Alex needs to walk.

  • 输入
  • First are two integers n (n<=15) and k (1 <= k<=n);
    Next contains two lines ,every line contains n-1 integers
    which represent the distance between two adjacent castles and the value is less than 100.
  • 输出
  • For each case output the answer represent shortest distance Alex needs to walk.
  • 样例输入
  • 4 3
    4 2 6
    2 10 2
  • 样例输出
  • 6
  • 提示
  • 来源
  • Tisuama@WUST
  • 操作

显示春菜