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;
#define ff first
#define ss second
#define pb push_back
//#define int long long
int p[200005];
int a[200005],mx,n,k,x;
int main(){
cin>>n>>x;
for(int i=1;i<=n;i++){
cin>>a[i];
}
vector <int> v;
for(int i=1;i<=n;i++){
k=lower_bound(v.begin(),v.end(),a[i])-v.begin();
if(k==v.size()){
v.pb(a[i]);
}else{
v[k]=a[i];
}
p[i]=k+1;
}
v.clear();
mx=max(mx,p[n]);
for(int i=n;i>=1;i--){
k=lower_bound(v.begin(),v.end(),x-a[i])-v.begin();
mx=max(mx,p[i]+k);
k=lower_bound(v.begin(),v.end(),-a[i])-v.begin();
if(k==v.size()){
v.pb(-a[i]);
}else{
v[k]=-a[i];
}
}
cout<<mx<<endl;
}
Compilation message (stderr)
glo.cpp: In function 'int main()':
glo.cpp:20:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | if(k==v.size()){
| ~^~~~~~~~~~
glo.cpp:35:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | if(k==v.size()){
| ~^~~~~~~~~~
# | 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... |