commit b80e63ba810301b05c973cf95caba956ec8c198a parent 8b321a709f927b016bc3e4557ced41a0ee9b981a Author: superpozycja <anna@superpozycja.net> Date: Wed, 30 Oct 2024 23:00:53 +0100 solve towers Diffstat:
A | sorting_and_searching/towers.cpp | | | 43 | +++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 43 insertions(+), 0 deletions(-)
diff --git a/sorting_and_searching/towers.cpp b/sorting_and_searching/towers.cpp @@ -0,0 +1,43 @@ +#include <bits/stdc++.h> + +using namespace std; + +using ui = unsigned int; +using l = long; +using ul = unsigned long; +using ll = long long; +using ull = unsigned long long; + +using vi = vector<int>; +using vui = vector<ui>; +using vl = vector<l>; +using vul = vector<ul>; +using vll = vector<ll>; +using vull = vector<ull>; + +void solve() +{ + int n; + cin >> n; + int k; + multiset<int> a; + for (int i = 0; i < n; i++) { + cin >> k; + auto it = a.upper_bound(k); + if (it == a.end()) { + a.insert(k); + } else { + a.erase(it); + a.insert(k); + } + } + + cout << a.size() << "\n"; +} + +int main() +{ + ios::sync_with_stdio(0); + cin.tie(0); + solve(); +}