#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define endl "\n"
#define vec vector<ll>
#define vecvec vector<vector<ll>>
using namespace std;
/*#define FileName ""
string Ghhhh = ".in";
string Ghhhhh = ".out";
ifstream Girdi(FileName + Ghhhh);
ofstream Cikti(FileName + Ghhhhh);
#define cin Girdi
#define cout Cikti*/
inline void solve(){
ll n,m;
cin >> n >> m;
vector<ll> a(n+1);
vector<ll> lis;
for(ll i = 1 ; i <= n ; i++){
ll x;
cin >> x;
a[i] = m * i - x;
}
lis.pb(0);
for(ll i = 1 ; i <= n ; i++){
ll j = upper_bound(lis.begin(),lis.end(),a[i]) - lis.begin();
if(j == lis.size()) lis.pb(a[i]);
else if(j != 0) lis[j] = a[i];
}
cout << n - (lis.size() - 1) << endl;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
ll t = 1;
//cin >> t;
while(t--){
solve();
}
}
# | 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... |