// +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+ //
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define ll long long
#define int long long
#define all(x) x.begin(), x.end()
#define seea(x) for(int i = 0; i < x; i++)
#define pb push_back
using namespace std;
int lnis(const vector<int>& a){
vector<int> dp;
for(int x : a){
auto it = upper_bound(dp.begin(), dp.end(), x, greater<int>());
if(it == dp.end()) dp.push_back(x);
else *it = x;
}
return (int)dp.size();
}
void solve(){
int n, mx; cin >> n >> mx;
vector<int> a(n);
seea(n) cin >> a[i];
vector<int> c;
for(int i = 1; i <= n; ++i){
if(i * mx >= a[i-1]){
c.push_back(a[i-1] - i * mx);
}
}
int keep = lnis(c);
cout << n - keep << endl;
}
signed main(){
fast;
int 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... |