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 main(){
int n, x; cin >> n >> x;
vector<long long> v(n+1, 0);
for(int i=1; i<=n; i++){
cin >> v[i];
}
vector<long long> lj;
lj.push_back(v[1]);
vector<int> elol(n+1, 0);
elol[1]=1;
for(int i=2; i<=n; i++){
int j = lower_bound(lj.begin(), lj.end(), v[i]) - lj.begin();
elol[i]=j+1;
if(j == lj.size()){
lj.push_back(0);
}
lj[j]=v[i];
}
lj.clear();
lj.push_back(-v[n]);
vector<int> hatul(n+2, 0);
if(v[n-1] < v[n]+x) hatul[n]=1;
for(int i=n-1; i>0; i--){
int j = lower_bound(lj.begin(), lj.end(), -v[i]) - lj.begin();
if(j == lj.size()){
lj.push_back(0);
}
lj[j]=-v[i];
hatul[i] = lower_bound(lj.begin(), lj.end(), -1*(v[i-1]-x)) - lj.begin();
}
for(int x : elol) cout << x << " ";
cout << endl;
for(int x : hatul) cout << x << " ";
cout << endl;
int maxi=0;
for(int i=0; i<=n; i++){
maxi=max(maxi, elol[i]+hatul[i+1]);
}
cout << maxi << endl;
return 0;
}
Compilation message (stderr)
glo.cpp: In function 'int main()':
glo.cpp:18:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | if(j == lj.size()){
| ~~^~~~~~~~~~~~
glo.cpp:30:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | if(j == lj.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... |