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;
const int MAXN = 200010;
int N, X;
int v[MAXN];
int main(){
cin.tie(NULL)->sync_with_stdio(false);
cin >> N >> X;
for(int i = 0; i < N; ++i) cin >> v[i];
vector<int> lis;
for(int i = 0; i < N; ++i){
{
auto it = lower_bound(lis.begin(), lis.end(), v[i]+X);
if(it == lis.end()) lis.push_back(v[i]+X);
else *it = v[i]+X;
}
{
auto it = lower_bound(lis.begin(), lis.end(), v[i]);
if(it == lis.end()) lis.push_back(v[i]);
else *it = v[i];
}
}
cout << lis.size() << "\n";
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |