# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
754336 | sangeraf | Global Warming (CEOI18_glo) | C++17 | 109 ms | 5972 KiB |
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]=elol[i-1];
if(j == lj.size()){
lj.push_back(0);
elol[i]++;
}
lj[j]=v[i];
}
lj.clear();
lj.push_back(-v[n-1]);
vector<int> hatul(n+2, 0);
hatul[n]=1;
for(int i=n-1; i>0; i--){
int j = lower_bound(lj.begin(), lj.end(), -v[i]) - lj.begin();
hatul[i]=hatul[i+1];
if(j == lj.size()){
lj.push_back(0);
hatul[i]++;
}
lj[j]=-v[i];
}
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)
# | 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... |