From aac871e5ec521b35e226a4948329dd285e70dcf3 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Mon, 15 Nov 2021 15:30:25 +0800 Subject: [PATCH] =?UTF-8?q?895.=20=E6=9C=80=E9=95=BF=E4=B8=8A=E5=8D=87?= =?UTF-8?q?=E5=AD=90=E5=BA=8F=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acwing.com/problem/content/submission/code_detail/8843660/ --- AcWing/895/895.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 AcWing/895/895.cpp diff --git a/AcWing/895/895.cpp b/AcWing/895/895.cpp new file mode 100644 index 00000000..5cfd727a --- /dev/null +++ b/AcWing/895/895.cpp @@ -0,0 +1,23 @@ +#include + +using namespace std; + +int n, a[1005], f[1005], ans; + +int main() { + 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] = max(f[i], f[j] + 1); + } + } + ans = max(ans, f[i]); + } + cout << ans << endl; + return 0; +}