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 dude(vector<int>& haha, int x) {
int l = 0,r = haha.size()-1;
while(l < r) {
int m = (l+r+1)/2;
if(haha[m] < x) {
l = m;
}
else {
r = m-1;
}
}
return l;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,x,a,ans = 0;
cin >> n >> x;
vector<int> haha(n+1,INT_MAX);
vector<int> bruh(n+1,INT_MAX);
haha[0] = 0;
bruh[0] = 0;
for(int i = 1; i <= n; i++) {
cin >> a;
int c = dude(haha,a);
ans = max(ans,c+1);
haha[c+1] = a;
c = dude(bruh,a);
ans = max(ans,c+1);
bruh[c+1] = a;
c = dude(haha,a+x);
ans = max(ans,c+1);
bruh[c+1] = a;
}
cout << ans;
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... |