Cod sursa(job #3185668)

Utilizator verde.cristian2005Verde Flaviu-Cristian verde.cristian2005 Data 19 decembrie 2023 20:16:07
Problema Subsir crescator maximal Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.8 kb
#include <bits/stdc++.h>
using namespace std;

#ifndef HOME
	ifstream in("aib.in");
	ofstream out("aib.out");
	#define cin in
	#define cout out
#endif

int best[100001];
int v[100001], vec[100001];

int n;

int cautbin(int val)
{
	int r = 0, pas = 1 << 16;
	while(pas)
	{
		if(r + pas <= n && vec[r + pas] <= val)
			r += pas;
		pas /= 2;
	}
	return r;
}

int main()
{
#ifdef HOME
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
#endif // HOME
    int max1 = 0;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> v[i];
		vec[i] = v[i];
	}
	sort(vec + 1, vec + n + 1);
	for(int i = 1; i <= n; i++)
	{
		for(int j = 0; j < v[i]; j++)
			best[v[i]] = max(best[v[i]], best[j] + 1);
		max1 = max(max1, best[v[i]]);
	}
	cout << max1;
    return 0;
}