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 <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <iterator>
#include <deque>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
using namespace std;
typedef long long ll;
ll minLIS(vector<ll> &a, ll st){
multiset<ll> s;
s.insert(0);
ll ans = 1;
auto cur = s.begin();
for (ll u: a){
auto it = s.lower_bound(u-st);
if (it != s.end()){
bool flag = false;
if (it == cur){
ans++;
flag = true;
}
s.erase(it);
s.insert(u);
if (flag) {
cur = s.find(u);
}
}else{
s.insert(u);
}
}
return ans;
}
int main() {
ll n, m; cin >> n >> m;
vector<ll> a(n);
for (int i = 0; i < n; i++){
cin >> a[i];
}
cout << n+1-minLIS(a, m) << endl;
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... |