# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
170006 | mhy908 | Global Warming (CEOI18_glo) | C++14 | 89 ms | 5880 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
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const LL llinf=9000000000000000000;
const int inf=2000000000;
int n, x;
int lis[200010], lds[200010], ans, arr[200010];
pair<int, int> change[200010];
int main()
{
scanf("%d %d", &n, &x);
for(int i=1; i<=n; i++){
scanf("%d", &arr[i]);
lis[i]=inf;
}
for(int i=1; i<=n; i++){
int it=lower_bound(lis+1, lis+n+1, arr[i])-lis;
change[i]=mp(it, lis[it]);
lis[it]=arr[i];
ans=max(ans, it);
}
for(int i=n; i>=1; i--){
int it=lower_bound(lds+1, lds+n+1, -arr[i])-lds;
lds[it]=-arr[i];
lis[change[i].F]=change[i].S;
int jt=lower_bound(lis+1, lis+n+1, arr[i]+x)-lis-1;
ans=max(ans, it+jt);
}
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... |