# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
259934 | Kenzo_1114 | Global Warming (CEOI18_glo) | C++17 | 83 ms | 5152 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;
const int MAXN = 200010;
const long long int INF = 2e10 + 9;
int n;
long long int x, t[MAXN], dp[MAXN], ans[MAXN];
int main ()
{
scanf("%d %lld", &n, &x);
dp[0] = INF;
for(int i = 1; i <= n; i++)
scanf("%lld", &t[i]), dp[i] = INF;
long long int ANS = 0;
for(int i = 1; i <= n; i++)
{
int it = lower_bound(dp, dp + n, t[i]) - dp;
dp[it] = t[i];
ans[i] = it + 1;
ANS = max(ANS, ans[i]);
}
dp[0] = INF;
for(int i = 1; i <= n; i++) t[i] = -t[i], dp[i] = INF;
for(int i = n; i > 0; i--)
{
int id = lower_bound(dp, dp + n, t[i] + x) - dp;
int it = lower_bound(dp, dp + n, t[i]) - dp;
dp[it] = t[i];
ANS = max(ANS, id + ans[i]);
}
printf("%lld\n", 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... |