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;
long long mod = 1e9 + 7;
int main() {
//freopen("cowjog.in", "r", stdin);
//freopen("cowjog.out", "w", stdout);
int n, m;
cin >> n >> m;
vector<int> vec(n);
for (int i = 0; i < n; i++) {
int a;
cin >> a;
a -= (i + 1) * m;
a *= -1;
vec[i] = a;
}
vector<int> dp(n + 1, 1e9 + 7);
dp[0] = -1e9 - 7;
for (int i = 0; i < n; i++) {
if (vec[i] < 0) {
continue;
}
int l = (int) (upper_bound(dp.begin(), dp.end(), vec[i]) - dp.begin());
dp[l] = vec[i];
}
int max = 0;
for (int l = 0; l <= n; l++) {
if (dp[l] != 1e9 + 7) {
max = l;
}
}
cout << n - max << "\n";
}
# | 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... |