#include "bits/stdc++.h"
using namespace std;
#define ll long long
const int MOD = 1e9+7;
const int INF = 1e9;
/**
* tle
*/
void solve() {
int n, x;
cin >> n >> x;
vector<int> t(n);
for (int i = 0; i < n; i++) {
cin >> t[i];
}
int ans = 1;
for (int i = 0; i < n; i++) {
t[i] -= x;
vector<int> dp;
for (int j = 0; j < n; j++) {
auto it = lower_bound(dp.begin(), dp.end(), t[j]);
if (it == dp.end()) {
dp.push_back(t[j]);
} else {
*it = t[j];
}
}
ans = max(ans, (int) dp.size());
}
cout << ans << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// freopen("input.in", "r", stdin);
// freopen("output.out", "w", stdout);
// int T = 1;
// cin >> T;
// while (T--) {
solve();
// }
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... |