From a4a780f56e291b934d2e9c5ad6cb0dfde4d2a94b Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sun, 3 Apr 2022 10:40:41 +0800 Subject: [PATCH] =?UTF-8?q?1289.=20=E6=8B=A6=E6=88=AA=E5=AF=BC=E5=BC=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit http://ybt.ssoier.cn:8088/statusx.php?runidx=15580224 --- ybt/1289/1289.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 ybt/1289/1289.cpp diff --git a/ybt/1289/1289.cpp b/ybt/1289/1289.cpp new file mode 100644 index 00000000..d0f5127e --- /dev/null +++ b/ybt/1289/1289.cpp @@ -0,0 +1,30 @@ +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 20005; + +int n, a[N], f[N], ans; + +int main() { + std::ios::sync_with_stdio(false); + + cin >> n; + for (int i = 1; i <= n; i++) { + cin >> a[i]; + } + + for (int i = 1; i <= n; i++) { + f[i] = 1; + for (int j = 1; j < i; j++) { + if (a[j] >= a[i]) f[i] = std::max(f[i], f[j] + 1); + } + ans = std::max(ans, f[i]); + } + + cout << ans << endl; + + return 0; +}