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 <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 200010;
int A[maxn];
int lis[maxn];
int main() {
ios::sync_with_stdio(false); cin.tie(0), cout.tie(0);
int N, M; cin >> N >> M;
for (int i = 1; i <= N; i++) {
cin >> A[i];
A[i] -= i * M;
}
reverse(A, A + N + 1);
memset(lis, 60, sizeof lis);
int mx = 0;
for (int i = 0; i <= N; i++) {
if (A[i] > 0) continue;
int idx = upper_bound(lis, lis + N, A[i]) - lis;
lis[idx] = A[i];
mx = max(mx, idx + 1);
}
cout << N + 1 - mx << 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... |