From 69b14c751436110cae58fde3b41930597e360249 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sat, 2 Apr 2022 09:18:45 +0800 Subject: [PATCH] =?UTF-8?q?1260.=20=E3=80=90=E4=BE=8B9.4=E3=80=91=E6=8B=A6?= =?UTF-8?q?=E6=88=AA=E5=AF=BC=E5=BC=B9(Noip1999)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit http://ybt.ssoier.cn:8088/statusx.php?runidx=15563317 --- ybt/1260/1260.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 ybt/1260/1260.cpp diff --git a/ybt/1260/1260.cpp b/ybt/1260/1260.cpp new file mode 100644 index 00000000..4e8b3563 --- /dev/null +++ b/ybt/1260/1260.cpp @@ -0,0 +1,36 @@ +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 20005; + +int n, a[N], f[N], ans1, ans2; + +int main() { + std::ios::sync_with_stdio(false); + + while (cin >> a[++n]) {} + + 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); + } + ans1 = std::max(ans1, f[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); + } + ans2 = std::max(ans2, f[i]); + } + + cout << ans1 << endl + << ans2 << endl; + + return 0; +}