menu ZJOJ
account_circle 请登录
home
首页
book
题目
apps
分类
play_circle_outline
状态
assessment
竞赛
assignment
作业
equalizer
排名
assignment_ind
登录
person_add
注册
1572: 租用游艇
时间限制:1.000s
内存限制:128MB

题目描述

长江游艇俱乐部在长江上设置了 lns="http://www.w3.org/1998/Math/MathML">n 个游艇出租站 lns="http://www.w3.org/1998/Math/MathML">1,2,\cdots,n。游客可在这些游艇出租站租用游艇,并在下游的任何一个游艇出租站归还游艇。游艇出租站 lns="http://www.w3.org/1998/Math/MathML">i 到游艇出租站 lns="http://www.w3.org/1998/Math/MathML">j 之间的租金为 lns="http://www.w3.org/1998/Math/MathML">r(i,j)lns="http://www.w3.org/1998/Math/MathML">1\le i\lt j\le n)。试设计一个算法,计算出从游艇出租站 lns="http://www.w3.org/1998/Math/MathML">1 到游艇出租站 lns="http://www.w3.org/1998/Math/MathML">n 所需的最少租金。

输入格式

第一行中有一个正整数 lns="http://www.w3.org/1998/Math/MathML">n,表示有 lns="http://www.w3.org/1998/Math/MathML">n 个游艇出租站。接下来的 lns="http://www.w3.org/1998/Math/MathML">n-1 行是一个半矩阵 lns="http://www.w3.org/1998/Math/MathML">r(i,j)lns="http://www.w3.org/1998/Math/MathML">1\le i<j\le n)。

输出格式

输出计算出的从游艇出租站 lns="http://www.w3.org/1998/Math/MathML">1 到游艇出租站 lns="http://www.w3.org/1998/Math/MathML">n 所需的最少租金。

样例输入 content_copy

3
5 15
7

样例输出 content_copy

12

提示/说明

,保证计算过程中任何时刻数值都不超过 lns="http://www.w3.org/1998/Math/MathML">10^6

分类