This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
vi a;
int lis(int n) {
int INF = INT_MAX;
vector<int> d(n+1, INF);
d[0] = -INF;
for (int i = 0; i < n; i++) {
int j = upper_bound(d.begin(), d.end(), a[i]) - d.begin();
if (d[j-1] < a[i] && a[i] < d[j]) d[j] = a[i];
}
int ans = 0;
for (int i = 0; i <= n; i++) {
if (d[i] < INT_MAX)
ans = i;
}
return ans;
}
int main(){
int n;
cin>>n;
a.resize(n,0);
for(int i=0; i<n; i++){
cin>>a[i];
}
cout<<lis(n)<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |