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() {
int n, m; cin >> n >> m;
vector<int> arr(n);
for (int i = 0; i < n; i++) {
int v; cin >> v;
arr[i] = v - m * (i + 1);
}
reverse(arr.begin(), arr.end());
vector<int> res(n + 1, INT_MAX);
res[0] = INT_MIN;
for (int i = 0; i < n; i++) {
if (arr[i] > 0) continue;
int l = upper_bound(res.begin(), res.end(), arr[i]) - res.begin();
res[l] = arr[i];
}
cout << n - (lower_bound(res.begin(), res.end(), INT_MAX) - res.begin() - 1) << endl;
}
# | 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... |