이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const long long MAX=2*1e5+10;
long long pr[MAX];
long long niza[MAX];
int main()
{
long long n,x;
cin>>n>>x;
for(long long i=0; i<n; i++)cin>>niza[i];
vector<long long> help(n);
for(long long i=0; i<n; i++)help[i]=INT_MAX;
long long res=0;
for(long long i=0; i<n; i++)
{
long long nw=lower_bound(help.begin(),help.end(),niza[i])-help.begin();
help[nw]=niza[i];
pr[i]=nw+1;
res=max(res,pr[i]);
}
for(long long i=0; i<n; i++)help[i]=INT_MAX;
for (long long i=n-1; i>=0; i--) {
long long nw=lower_bound(help.begin(),help.end(),-niza[i]+x)-help.begin();
res=max(res,pr[i]+nw);
long long tmp=lower_bound(help.begin(),help.end(),-niza[i])-help.begin();
help[tmp]=-niza[i];
}
cout<<res<<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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |