From 96254947699986c59f0dc63d69fd4b76bd3ed43e Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 6 Jul 2026 19:08:08 +0200 Subject: Initial commit --- 02_sorting_and_searching/towers_1063.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 02_sorting_and_searching/towers_1063.cpp (limited to '02_sorting_and_searching/towers_1063.cpp') diff --git a/02_sorting_and_searching/towers_1063.cpp b/02_sorting_and_searching/towers_1063.cpp new file mode 100644 index 0000000..b0656f3 --- /dev/null +++ b/02_sorting_and_searching/towers_1063.cpp @@ -0,0 +1,17 @@ +#include +#include +#include + +int main() { + size_t n; + std::cin >> n; + std::vector v; + for (size_t i = 0; i < n; i++) { + int x; + std::cin >> x; + auto it = std::upper_bound(v.begin(), v.end(), x); + if (it == v.end()) v.push_back(x); + else *it = x; + } + std::cout << v.size() << "\n"; +} -- cgit v1.3