HelloooO!!! to all Visitors!!!
PROBLEM
I am getting some sort of infinite loop in codechef and wrong answer. I dont understand WHYYYYYYY!. Is there any Great Human Who Could HELP ME?
Thanks
#include <bits/stdc++.h>
using namespace std;
int lis(int a[],int n){
if(n==0){
return 0;
}
int min_last[n]={0};
int len = 1;
min_last[0]=a[0];
for(int i=1;i<n;++i){
auto lb = lower_bound(min_last,min_last+len,a[i]); // gives us pointer of that position
if(lb==min_last+len)
min_last[len++] = a[i];
else
*lb = a[i];
}
return len;
}
int main(){
int t,n;
cin>>t;
while(t--){
cin>>n;
int a[n];
for(int i=0;i<n;++i){
cin>>a[i];
}
cout<<lis(a,n)<<"\n";
}
return 0;
}
