Submission #161188

#TimeUsernameProblemLanguageResultExecution timeMemory
161188rama_pangGlobal Warming (CEOI18_glo)C++14
28 / 100
2066 ms3832 KiB
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;

int N, X;
int A[200005];
int last[200005];

int lis(int n) {
    for (int i = 0; i <= N; i++) last[i] = INF;
    last[0] = -INF;
    for (int i = 0; i < n; i++) A[i] -= X;
    for (int i = 0; i < N; i++) {
        int j = upper_bound(last, last + N + 1, A[i]) - last;
        if (last[j - 1] < A[i] && A[i] < last[j]) last[j] = A[i];
    }
    for (int i = 0; i < n; i++) A[i] += X;
    int res = 0;
    for (int i = 0; i <= N; i++) {
        if (last[i] < INF) res = i;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> N >> X;
    for (int i = 0; i < N; i++) cin >> A[i];

    int ans = 0;
    for (int i = 0; i < N; i++) ans = max(ans, lis(i));
    cout << ans << "\n"; 

}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...