# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
495563 | aris12345678 | Global Warming (CEOI18_glo) | C++14 | 72 ms | 5372 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 mxN = 200005;
int t[mxN], dp1[mxN], pref[mxN], dp2[mxN];
int main() {
int n, x;
scanf("%d %d", &n, &x);
for(int i = 0; i < n; i++)
scanf("%d", &t[i]);
fill(dp1, dp1+n, INT_MAX);
int ans = 0;
for(int i = 0; i < n; i++) {
int pos = lower_bound(dp1, dp1+n, t[i])-dp1;
dp1[pos] = t[i];
pref[i] = pos+1;
ans = max(ans, pref[i]);
}
fill(dp2, dp2+n, INT_MAX);
for(int i = n-1; i >= 0; i--) {
int res = lower_bound(dp2, dp2+n, -t[i]+x)-dp2;
ans = max(ans, pref[i]+res);
int pos = lower_bound(dp2, dp2+n, -t[i])-dp2;
dp2[pos] = -t[i];
}
printf("%d\n", ans);
return 0;
}
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... |