# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
260697 | bigg | Global Warming (CEOI18_glo) | C++14 | 2079 ms | 7032 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;
typedef long long ll;
const int MAXN = 2e5 + 10;
const ll INF =1e18;
ll dp[MAXN], v[MAXN], neg[MAXN];
int ans1[MAXN];
int main(){
int n;
ll x;
scanf("%d %lld", &n, &x);
for(int i = 1; i <= n; i++) scanf("%lld", &v[i]), dp[i] = INF, neg[i] = -v[i];
//dp[0] = INF;
int ans = -1;
for(int i = 0; i <= n; i++) dp[i] = INF;
for(int i = 1; i <= n; i++){
int it1 = lower_bound(dp, dp + n, v[i]) - dp;
dp[it1] = v[i];
ans1[i] = it1 +1;
ans = max(ans, it1 + 1);
}
for(int k = -x; k <= x; k++){
for(int i = 0; i <= n; i++) dp[i] = INF;
for(int i = n; i; i--){
int it1 = lower_bound(dp, dp + n, neg[i] +k) - dp;
int it2 = lower_bound(dp, dp + n, neg[i]) - dp;
dp[it2] = neg[i];
ans = max(ans, it1 + ans1[i]);
//printf("%\n");
}
}
printf("%d\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... |