#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
long long M;
cin >> N >> M;
vector<long long> dp;
dp.reserve(N);
for (int i = 1; i <= N; i++) {
long long a;
cin >> a;
long long b = a - i * M;
long long c = -b;
auto it = upper_bound(dp.begin(), dp.end(), c);
if (it == dp.end())
dp.push_back(c);
else
*it = c;
}
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... |