#P1359. 租用游艇

    ID: 356 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>动态规划,dp图论福建省历届夏令营

租用游艇

Description

The Yangtze River Yacht Club has set up nn yacht rental stations 1,2,,n1,2,\dots,n along the Yangtze River. Tourists can rent a yacht at any of these stations and return it at any downstream station. The rent between yacht rental station ii and yacht rental station jj is ri,jr_{i,j} (1i<jn1\le i\lt j\le n). Design an algorithm to compute the minimum total rent needed to travel from yacht rental station 11 to yacht rental station nn.

Input Format

The first line contains a positive integer nn, indicating there are nn yacht rental stations.
The next n1n-1 lines give a half matrix ri,jr_{i,j} (1i<jn1\le i<j\le n): for each ii from 11 to n1n-1, the ii-th of these lines contains nin-i integers ri,i+1,ri,i+2,,ri,nr_{i,i+1}, r_{i,i+2}, \dots, r_{i,n}.

Output Format

Output the minimum total rent required to travel from yacht rental station 11 to yacht rental station nn.

3
5 15
7
12

Hint

1n2001\le n\le 200, and it is guaranteed that at any time during the computation, all numbers do not exceed 10610^6.

Translated by ChatGPT 5