# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
586609 | aris12345678 | Global Warming (CEOI18_glo) | C++14 | 48 ms | 4424 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 main() {
int N, X;
scanf("%d %d", &N, &X);
vector<int> A(N);
for(int i = 0; i < N; i++)
scanf("%d", &A[i]);
vector<int> LIS;
vector<int> INC(N, 0);
LIS.push_back(A[0]);
INC[0] = 1;
for(int i = 1; i < N; i++) {
int pos = lower_bound(LIS.begin(), LIS.end(), A[i])-LIS.begin();
INC[i] = pos+1;
if(pos < LIS.size())
LIS[pos] = A[i];
else
LIS.push_back(A[i]);
}
LIS.clear();
LIS.push_back(-A[N-1]);
int ans = 0;
for(int i = N-2; i >= 0; i--) {
int len = lower_bound(LIS.begin(), LIS.end(), -A[i]+X)-LIS.begin();
ans = max(ans, INC[i]+len);
int pos = lower_bound(LIS.begin(), LIS.end(), -A[i])-LIS.begin();
if(pos < LIS.size())
LIS[pos] = -A[i];
else
LIS.push_back(-A[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... |