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 false
using namespace std;
const int MAX_N = 2e5 + 10;
int a[MAX_N];
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int N, M;
cin >> N >> M;
for(int i = 1; i <= N; i++) {
cin >> a[i];
}
vector <int> vec;
for(int i = 1; i <= N; i++) {
if(i * M >= a[i]) {
vec.push_back(i * M - a[i]);
}
}
vector <int> lnds;
for(auto v : vec) {
auto it = upper_bound(lnds.begin(), lnds.end(), v);
if(it == lnds.end()) {
lnds.push_back(v);
}
else {
*it = v;
}
}
cout << N - lnds.size();
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... |