From f590742cf9bd160a3f5b12187d7474aeb4eb6edf Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Wed, 4 Nov 2020 07:34:05 +0800 Subject: [PATCH] =?UTF-8?q?P1359=20=E7=A7=9F=E7=94=A8=E6=B8=B8=E8=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R41199618 --- problem/P1359/P1359.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 problem/P1359/P1359.cpp diff --git a/problem/P1359/P1359.cpp b/problem/P1359/P1359.cpp new file mode 100644 index 00000000..bb825292 --- /dev/null +++ b/problem/P1359/P1359.cpp @@ -0,0 +1,22 @@ +#include + +using namespace std; + +int main() { + int n, t, a[205][205], f[205]; + cin >> n; + for (int i = 1; i <= n; i++) { + for (int j = i + 1; j <= n; j++) { + cin >> a[i][j]; + } + f[i] = 0x3f3f3f; + } + f[n] = 0; + for (int i = n-1; i >= 0; i--) { + for (int j = i + 1; j <= n; j++) { + f[i] = min(f[i], f[j] + a[i][j]); + } + } + cout << f[1] << endl; + return 0; +}