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_base::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
vector<int> a(n + 1, 0);
for (int i = 1; i <= n; ++i) {
cin >> a[i];
a[i] -= i * m;
}
reverse(a.begin(), a.end());
int res = 0;
vector<int> f(a.size() + 1, 1e9);
f[0] = -1e9;
for (int x : a) {
res = upper_bound(f.begin(), f.end(), x) - f.begin();
f[res] = x;
}
cout << n - (res - 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... |