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 int long long
using P = std::pair<int, int>;
int32_t main() {
std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0);
int N, M; std::cin >> N >> M;
std::vector<int> a(N + 1);
std::vector<P> b(N + 1), lis(N);
int ans = 0;
for(int i = 1; i <= N; i++){
std::cin >> a[i];
b[i].first = -(a[i] - M * i);
b[i].second = i;
if(a[i] > M * i) continue;
auto be = lis.begin();
auto e = lis.begin() + ans;
auto it = std::lower_bound(be, e, b[i]);
if(it == e){
lis[ans++] = b[i];
}else{
*it = b[i];
}
}
std::cout << N - ans << '\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... |