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>
#define DEBUG(x) cout << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
int main() {
ll n, m;
cin >> n >> m;
vector<ll> v(n + 1);
v[0] = 0;
for (int i = 1; i <= n; ++i) {
ll x;
cin >> x;
v[i] = i * m - x;
}
vector<ll> dp;
dp.push_back(0);
for (int i = 1; i <= n; ++i) {
auto it = upper_bound(dp.begin(), dp.end(), v[i]);
if (it == dp.end()) {
dp.push_back(v[i]);
} else {
int pos = it - dp.begin();
if (pos == 0) continue;
dp[pos] = v[i];
}
}
cout << n + 1 - dp.size();
}
# | 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... |