aboutsummaryrefslogtreecommitdiff
path: root/02_sorting_and_searching/towers_1063.cpp
blob: b0656f3bf28507b3b7224378b75c502dbd2cf3a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
	size_t n;
	std::cin >> n;
	std::vector<int> 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";
}

Generated with cgit - Back to sebastiano.tronto.net