Renting Boats

Renting Boats

http://acm.fzu.edu.cn/problem.php?pid=1436


Time Limit:1sMemory limit:32M
Accepted Submit:187Total Submit:412

Problem Description

Yangtse Rive Barge Club has set up n barge hiring stops numbered 1, 2, … , n along the Changjiang

River. Passengers can hire barges from any of these stops, and return the barges to one of the stops afterward. The rent for an barge from stop i to stop j is r(i,j) (1<=i,j<=n). Your task is to design an

algorithm to minimize the rent of hiring barges when you traveling from stop 1 to stop n.

Input

There are multiple test cases. The first line of each case contains an integer n indicating the number of the stops (n<=200). The following n-1 lines are the rent between any two stops. The ith following line contains n-i integers indicating r(i,j) (i < j <= n).

Output

For each case, output one line representing the minimal rent.

Sample Input

3
5 15
7

Sample Output

12
 
有关图的题目,用Dijkstra算法
 
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值