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;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n, m;
cin >> n >> m;
vector <int> a(n + 1), b(n + 1);
for(int i = 1; i <= n; i++) {
cin >> a[i];
b[i] = m * i - a[i];
}
vector <int> lis;
for(int i = 1; i <= n; i++) {
if(b[i] < 0) continue;
if(lis.empty() || lis.back() <= b[i]) lis.push_back(b[i]);
else {
int ii = upper_bound(lis.begin(), lis.end(), b[i]) - lis.begin();
lis[ii] = b[i];
}
}
cout << n - (int)lis.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... |