This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define long long long int
#define DEBUG
using namespace std;
// @author: pashka
int main() {
ios::sync_with_stdio(false);
int n;
long m;
cin >> n >> m;
vector<long> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < n; i++) {
a[i] = i * m - a[i];
}
vector<long> d(n + 1, LLONG_MAX);
d[0] = 0;
int res = 0;
for (int i = 0; i < n; i++) {
int j = lower_bound(d.begin(), d.end(), a[i] + 1) - d.begin();
if (j > 0) {
d[j] = a[i];
res = max(res, j);
}
}
cout << n - res << "\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... |