#include <bits/stdc++.h>
#define pb push_back
#define pf push_front
using namespace std;
#define F first
#define S second
typedef long long ll;
#define pii pair <int, int>
#define pll pair <ll, ll>
typedef long double ld;
const ll N = 2 * 1e5 + 100, M = 4096 + 10, len = 21, inf = 1e18;
const ll mod = 1e9 + 7;
ll um(ll a, ll b){
return (1LL * a * b % mod + mod) % mod;
}
ll n, dp[N], a[N];
ll got(){
for(ll i = 1; i <= n; i++){
dp[i] = LLONG_MAX;
}
dp[0] = LLONG_MIN;
ll mx = 1;
for(ll i = 1; i <= n; i++){
ll k = lower_bound(dp, dp + n, a[i]) - dp;
if(a[i] > dp[k - 1]){
dp[k] = a[i];
mx = max(mx, k);
}
}
return mx;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
ll x, ans = 1;
cin >> n >> x;
for(ll i = 1; i <= n; i++){
cin >> a[i];
}
if(x == 0){
cout << got();
return 0;
}
for(ll k = -x; k <= x; k++){
for(ll i = 1; i <= n; i++){
for(ll j = i; j <= n; j++){
a[j] += k;
ans = max(ans, got());
}
for(ll j = i; j <= n; j++){
a[j] -= k;
}
}
}
cout << ans;
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... |