# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1103955 | vjudge1 | Global Warming (CEOI18_glo) | C++17 | 41 ms | 4308 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 <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int arr[200005];
int len[200005];
int mx,idx;
int main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
int n,x; cin >> n >> x;
for(int i=0;i<n;++i) cin >> arr[i];
vector<int> dp;
for(int i=0;i<n;++i){
idx=lower_bound(dp.begin(),dp.end(),arr[i])-dp.begin();
if(idx==dp.size()) dp.push_back(arr[i]);
else dp[idx]=arr[i];
len[i] = idx+1;
mx=max(mx,len[i]);
}
dp.clear();
for(int i=n-1;i>0;--i){
idx=lower_bound(dp.begin(),dp.end(),-arr[i]+x)-dp.begin();
mx=max(mx,len[i]+idx);
idx=lower_bound(dp.begin(),dp.end(),-arr[i])-dp.begin();
if(idx==dp.size()) dp.push_back(-arr[i]);
else dp[idx]=-arr[i];
}
cout << mx << endl;
}
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... |