From 59c3bcec2570e4335698e0bfe81a7aad4a662b6a Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sun, 3 Apr 2022 09:11:26 +0800 Subject: [PATCH] =?UTF-8?q?1288.=20=E4=B8=89=E8=A7=92=E5=BD=A2=E6=9C=80?= =?UTF-8?q?=E4=BD=B3=E8=B7=AF=E5=BE=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit http://ybt.ssoier.cn:8088/statusx.php?runidx=15577969 --- ybt/1288/1288.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 ybt/1288/1288.cpp diff --git a/ybt/1288/1288.cpp b/ybt/1288/1288.cpp new file mode 100644 index 00000000..4ffdf353 --- /dev/null +++ b/ybt/1288/1288.cpp @@ -0,0 +1,34 @@ +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 105; + +int n, g[N][N], f[N][N], ans; + +int main() { + std::ios::sync_with_stdio(false); + + cin >> n; + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= i; j++) { + cin >> g[i][j]; + } + } + + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= i; j++) { + f[i][j] = std::max(f[i - 1][j], f[i - 1][j - 1]) + g[i][j]; + } + } + + for (int i = 1; i <= n; i++) { + ans = std::max(ans, f[n][i]); + } + + cout << ans << endl; + + return 0; +}