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