#include <bits/stdc++.h>
using namespace std;
int32_t main() {
cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
vector<int> dp;
int n, m;
cin >> n >> m;
for(int i=1, x; i<=n; i++) {
cin >> x;
if(i*m-x>=0) {
int pos = upper_bound(dp.begin(), dp.end(), i*m-x)-dp.begin();
if(pos == dp.size()) dp.push_back(0);
dp[pos] = i*m-x;
}
}
cout << n - int(dp.size()) << '\n';
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... |