diff options
Diffstat (limited to '02_sorting_and_searching/towers_1063.cpp')
| -rw-r--r-- | 02_sorting_and_searching/towers_1063.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
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 @@ | |||
| 1 | #include <algorithm> | ||
| 2 | #include <iostream> | ||
| 3 | #include <vector> | ||
| 4 | |||
| 5 | int main() { | ||
| 6 | size_t n; | ||
| 7 | std::cin >> n; | ||
| 8 | std::vector<int> v; | ||
| 9 | for (size_t i = 0; i < n; i++) { | ||
| 10 | int x; | ||
| 11 | std::cin >> x; | ||
| 12 | auto it = std::upper_bound(v.begin(), v.end(), x); | ||
| 13 | if (it == v.end()) v.push_back(x); | ||
| 14 | else *it = x; | ||
| 15 | } | ||
| 16 | std::cout << v.size() << "\n"; | ||
| 17 | } | ||
