# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
170000 | mhy908 | Global Warming (CEOI18_glo) | C++14 | 41 ms | 3708 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>
#define pb push_back
using namespace std;
typedef long long LL;
const LL llinf=9000000000000000000;
int n;
LL x, arr[200010];
vector<LL> lis, lds;
int dplis[200010], dplds[200010], ans;
LL minlds[200010];
int main()
{
scanf("%d %lld", &n, &x);
for(int i=1; i<=n; i++)scanf("%lld", &arr[i]);
for(int i=n; i>=1; i--){
auto it=lower_bound(lds.begin(), lds.end(), -arr[i]);
if(it==lds.end())lds.pb(-arr[i]);
else *it=-arr[i];
dplds[i]=it-lds.begin()+1;
minlds[i]=-lds[dplds[i]-1];
}
minlds[n+1]=llinf;
ans=dplds[1];
for(int i=1; i<=n; i++){
auto it=lower_bound(lis.begin(), lis.end(), arr[i]);
if(it==lis.end())lis.pb(arr[i]);
else *it=min(arr[i], *it);
dplis[i]=lower_bound(lis.begin(), lis.end(), minlds[i+1]+x)-lis.begin();
ans=max(ans, dplis[i]+dplds[i+1]);
}
printf("%d", ans);
}
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... |