Pagini recente » Cod sursa (job #708890) | Cod sursa (job #845453) | Cod sursa (job #18626) | Cod sursa (job #1935573) | Cod sursa (job #1159052)
#include <fstream>
#include <set>
#include <array>
using namespace std;
const int MAXN = 100005;
int n,LIS=0;
array<int, MAXN> a;
void read()
{
ifstream fin("scmax.in");
fin>>n;
for (int i=0; i<n; ++i)
fin>>a[i];
fin.close();
}
void write()
{
ofstream fout("scmax.out");
fout<<LIS<<'\n';
fout.close();
}
void dp()
{
set<int> s;
for (int i=0; i<n; ++i)
{
set<int>::iterator position=s.find(a[i]);
if (position!=s.end())
continue;
s.insert(a[i]);
position=s.find(a[i]);
++position;
if (position!=s.end())
s.erase(position);
}
LIS=s.size();
}
int main()
{
read();
dp();
write();
return 0;
}