#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fi first
#define ll long long
#define se second
#define sz(x) ((int)(x).size())
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define Yes cout << "Yes\n"
#define No cout << "No\n"
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define per(i, a, b) for (int i = b - 1; i >= a; --i)
typedef vector<int> vi;
typedef pair<ll, ll> pii;
typedef vector<pii> vpi;
typedef long double ld;
const ll INF = 1e18;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 5;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int mod_pow(int a, int b, int m = MOD) {
int res = 1;
a %= m;
while (b) {
if (b & 1) res = res * a % m;
a = a * a % m;
b >>= 1;
}
return res;
}
int mod_inv(int a, int m = MOD) {
return mod_pow(a, m - 2, m);
}
bool is_prime(int n) {
if (n < 2) return false;
for (int i = 2; i * i <= n; ++i)
if (n % i == 0) return false;
return true;
}
vector<bool> prime(MAXN, true);
void sieve(int n) {
prime[0] = prime[1] = false;
for (int i = 2; i * i <= n; ++i)
if (prime[i])
for (int j = i * i; j <= n; j += i)
prime[j] = false;
}
ll dx[] = {-1, 0, 1, 0};
ll dy[] = {0, 1, 0, -1};
void solve(ll x, vi& a) {
vi te;
te.push_back(a[0]);
for (int i = 1; i < sz(a); i++) {
if (a[i] > te.back()) {
te.push_back(a[i]);
} else {
int idx = lower_bound(te.begin(), te.end(), a[i]) - te.begin();
te[idx] = a[i];
}
}
cout << te.size() << endl;
}
int main() {
ll n, x;
cin >> n >> x;
vi a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
solve(x, a);
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |