# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
973891 | vjudge1 | Global Warming (CEOI18_glo) | C++17 | 50 ms | 3864 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;
int n, d;
int main() {
scanf("%d %d", &n, &d);
vector<int> t(n), pref(n), c;
for (auto &e: t) scanf("%d", &e);
for (int i = 0; i < n; i++) {
auto lower = lower_bound(c.begin(), c.end(), t[i]);
if (lower == c.end()) c.emplace_back(t[i]), pref[i] = c.size();
else *lower = t[i], pref[i] = lower - c.begin() + 1;
}
int ans = c.size(); c.clear();
for (int i = n - 1; i >= 0; i--) {
auto lower = lower_bound(c.begin(), c.end(), -t[i] + d);
ans = max(ans, pref[i] + (int) (lower - c.begin()));
auto clower = lower_bound(c.begin(), c.end(), -t[i]);
if (clower == c.end()) c.emplace_back(-t[i]);
else *clower = -t[i];
}
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... |