LIS CODE WITH MULTISET
if we required repeated elements we use upper_bound(s.begin(),s.end(),g) if(it!=s.end()) then erase(it);
if repaeated elements are not required then we use---->>>> s.find(g); it++; if(it!=s.end()) then erase(it);
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
int main()
{
int n,g;
multiset<int> s;
multiset<int>::iterator it;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>g;
s.insert(g);
it = upper_bound(s.begin(), s.end(), g);
if(it!=s.end())
s.erase(it);
}
cout<<s.size()<<endl;
return 0;
}
Comments
Post a Comment