# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1103961 | vjudge1 | Global Warming (CEOI18_glo) | C++17 | 44 ms | 4340 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 N = 2e5 + 1;
const int INF = 2e9;
int arr[N] , ans;
int l[N] , r[N];
vector<int> dp;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int n,x; cin >> n >> x;
for (int i=1;i<=n;i++) cin >> arr[i];
for (int i=1;i<=n;i++) {
int idx = lower_bound(dp.begin(), dp.end(), arr[i]) - dp.begin();
l[i] = idx + 1;
if (idx==dp.size()) dp.push_back(arr[i]);
dp[idx] = arr[i];
}
dp.clear();
for(int i=n;i>=1;i--) {
int idx = lower_bound(dp.begin(), dp.end(), -arr[i] + x) - dp.begin();
r[i] = idx + 1;
idx = lower_bound(dp.begin(), dp.end(), -arr[i]) - dp.begin();
if (idx==dp.size()) dp.push_back(-arr[i]);
dp[idx] = -arr[i];
}
int ans = 0;
for (int i=1;i<=n;i++) ans = max(ans, l[i] + r[i] - 1);
cout << 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... |