From f5644225fc43630963697bf1e34aa1aa6ddd8ca9 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Sun, 1 Nov 2020 16:49:20 +0800 Subject: [PATCH] =?UTF-8?q?P1130=20=E7=BA=A2=E7=89=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R41016790 --- problem/P1130/P1130.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 problem/P1130/P1130.cpp diff --git a/problem/P1130/P1130.cpp b/problem/P1130/P1130.cpp new file mode 100644 index 00000000..7ac7774e --- /dev/null +++ b/problem/P1130/P1130.cpp @@ -0,0 +1,25 @@ +#include + +using namespace std; + +int main() { + long long n, m, a[2005][2005], f[2005][2005]; + cin >> n >> m; + for(int i = 1 ; i <= m ; i++) { + for(int j = 1 ; j <= n ; j++) { + cin >> a[j][i]; + } + } + for(int i = 1 ; i <= n ; i++) { + f[i-1][0] = f[i-1][m]; + for(int j = 1 ; j <= m ; j++) { + f[i][j] = a[i][j] + min(f[i-1][j], f[i-1][j-1]); + } + } + long long ans = f[n][1]; + for(int i = 2 ; i <= m ; i++) { + ans = min(ans, f[n][i]); + } + cout << ans << endl; + return 0; +}