# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1019187 | ivaziva | Global Warming (CEOI18_glo) | C++14 | 111 ms | 6604 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;
#define MAXN 200010
long long n,x;
long long a[MAXN],lis[MAXN];
vector<long long> dp;
int main()
{
cin>>n>>x;
for (long long i=1;i<=n;i++) cin>>a[i];
long long ans=0;
for (long long i=1;i<=n;i++)
{
long long poz=lower_bound(dp.begin(),dp.end(),a[i])-dp.begin();
if (poz==dp.size()) dp.push_back(a[i]);
else dp[poz]=a[i];
lis[i]=poz+1;ans=max(ans,lis[i]);
}
dp.clear();
for (long long i=n;i>=1;i--)
{
long long poz1=lower_bound(dp.begin(),dp.end(),x-a[i])-dp.begin();
ans=max(ans,poz1+lis[i]);
long long poz2=lower_bound(dp.begin(),dp.end(),a[i]*(-1))-dp.begin();
if (poz2==dp.size()) dp.push_back(a[i]*(-1));
else dp[poz2]=a[i]*(-1);
}
cout<<ans<<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... |