Any questions do not hesitate to contact.
#include <bits/stdc++.h>
using namespace std;
int Ceil(vector <long long int > & v, int l, int r, long long int key) {
while (r - l > 1) {
int m = l + (r - l) / 2;
if (v[m] >= key) r = m;
else l = m;
}
return r;
}
int LIS(vector <long long int> &v) {
if (v.size() == 0) return 0;
vector <long long int> tail(v.size(), 0);
int length = 1;
tail[0] = v[0];
for (size_t i = 1; i < v.size(); i++) {
if (v[i] < tail[0]) tail[0] = v[i];
else if (v[i] > tail[length - 1]) tail[length++] = v[i];
else tail[Ceil(tail, -1, length - 1, v[i])] = v[i];
}
return length;
}
int main() {
int n;
while(scanf("%d",&n) && n!=0){
vector<long long int> precios;
long long int precio;
for (int i=0; i<n; i++) { scanf("%lld",&precio); precios.push_back(precio);}
printf("%d\n",LIS(precios));
}
return 0;
}
Keep in touch with Isaac Lozano Osorio!