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;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define N 200200
int n , x , rt , p , b[N] , a[N] , lis[N];
signed main(){
cin.tie(0)->sync_with_stdio(0);
cin >> n >> x , memset(b , 0x3f , sizeof b);
for (int i = 1 ; i <= n ; i ++)
cin >> a[i] , p = lower_bound(b + 1,b + n + 1,a[i]) - b , rt = max(rt,p) , lis[i] = p , b[p] = a[i];
memset(b , 0x3f , sizeof b);
for (int i = n ; i ; i --){
p = lower_bound(b + 1,b + n + 1,-a[i]) - b;
rt = max(rt , p + lis[i] - 1);
p = lower_bound(b + 1,b + n + 1,-a[i]-x) - b , b[p] = -a[i]-x;
}
cout << rt << '\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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |