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>
#define int long long
#define fi first
#define se second
#define keish ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
int n, x;
signed main(){
keish;
cin >> n >> x;
vector<int> a(n + 1);
for(int i = 1; i <= n; i++) cin >> a[i];
vector<int> dp(n + 1, 1e18);
dp[0] = -1e18;
for(int i = 1; i <= n; i++){
int j = upper_bound(dp.begin(), dp.end(), a[i]) - dp.begin();
if(dp[j - 1] < a[i] && a[i] < dp[j]) dp[j] = a[i];
}
int ans = 0;
for(int i = n; i >= 1; i--){
if(dp[i] != 1e18){
ans = i;
break;
}
}
cout << ans << endl;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |