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>
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, m;
std::cin >> n >> m;
std::vector<int> a(n + 1, 0);
for (int i = 1; i <= n; ++i) {
std::cin >> a[i];
a[i] = m * i - a[i];
}
std::vector<int> dp;
for (int i = 0; i <= n; ++i) {
if (a[i] >= 0) {
auto it = std::lower_bound(dp.begin(), dp.end(), a[i] + 1);
if (it == dp.end()) {
dp.push_back(a[i]);
}
else {
*it = a[i];
}
}
}
std::cout << n + 1 - dp.size() << "\n";
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... |