//{
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <bitset>
//}
using namespace std;
typedef long long ll;
int f (vector<int> &a) {
vector<int> mn;
for (int x : a) {
int pos = upper_bound(mn.begin(), mn.end(), x) - mn.begin();
if (pos == mn.size()) mn.push_back(x);
else mn[pos] = x;
}
return mn.size();
}
void solve () {
int n, m; cin >> n >> m;
vector<int> a(n);
for (int &x : a) cin >> x;
vector<int> v;
for (int i = 1; i <= n; i++) {
if (i * m >= a[i - 1]) {
v.push_back(i * m - a[i - 1]);
}
}
cout << n - f(v);
}
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
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... |