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;
int n, X, a[200001], res1[200001], res2[200001], L[200001];
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> X;
for (int i = 1; i <= n; i++) cin >> a[i];
int lis = 0;
for (int i = n; i >= 1; i--) {
int pos = upper_bound(L,L + lis, a[i]) - L;
L[pos] = a[i];
res1[i] = pos + 1;
lis = max(lis, pos + 1);
}
for (int i = 1; i <= n; i++) a[i] -= X;
memset(L,0,sizeof L);
lis = 0;
for (int i = 1; i <= n; i++) {
int pos = upper_bound(L,L + lis, a[i]) - L;
L[pos] = a[i];
res2[i] = pos + 1;
lis = max(lis, pos + 1);
}
int res = 0;
for (int i = 1; i <= n; i++)
res = max(res,res1[i] + res2[i] - 1);
cout << res;
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... |