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;
const int N = 2e5 + 5;
int a[N];
int n,m;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
//freopen("file.inp","r",stdin);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> a[i];
a[i] -= i * m;
}
vector <int> lis(n, 1e9 + 1);
lis[0] = -1e9;
int st = 1;
int ans = 0;
int res = 0;
while (a[st] > 0) {
st++;
ans++;
}
for (int i = n; i >= st; i--) {
int len = upper_bound(lis.begin(), lis.end(), a[i]) - lis.begin();
lis[len] = a[i];
res = max(res, len);
//cout << a[i] << "\n";
}
cout << (n - st - res + 1) + ans;
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... |