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>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m; cin >> n >> m;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
int v; cin >> v;
a[i] = v - m * (i + 1);
}
reverse(a.begin(), a.end());
vector<int> d(n + 1, INT32_MAX);
d[0] = INT32_MIN;
for (int i = 0; i < n; ++i) {
if (a[i] > 0) continue;
int l = upper_bound(d.begin(), d.end(), a[i]) - d.begin();
d[l] = a[i];
}
cout << n - (lower_bound(d.begin(), d.end(), INT32_MAX) - d.begin() - 1) << '\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... |