Submission #161217

# Submission time Handle Problem Language Result Execution time Memory
161217 2019-11-01T12:42:53 Z rama_pang Global Warming (CEOI18_glo) C++14
37 / 100
85 ms 6648 KB
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint INF = 1e15;

lint N, X;
lint A[200005];
lint lis[200005];
lint lds[200005];
lint anslis[200005];


lint LIS() {
    for (int i = 0; i <= N; i++) lis[i] = INF, lds[i] = -INF;
    lis[0] = -INF, lds[N] = INF;

    lint res = 0;

    for (lint i = 0; i < N; i++) {
        lint j = upper_bound(lis, lis + N + 1, A[i]) - lis;
        if (lis[j - 1] < A[i] && A[i] < lis[j]) lis[j] = A[i], res = max(res, j);
        anslis[i] = j;
    }

    for (lint i = N - 1; i >= 0; i--) {
        lint j = upper_bound(lds, lds + N + 1, A[i] - X) - lds; 
        res = max(res, anslis[i] + N - j);
        
        j = lower_bound(lds, lds + N + 1, A[i]) - lds;
        if (lds[j - 1] < A[i] && A[i] < lds[j]) lds[j - 1] = A[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];

    lint ans = LIS();
    cout << ans << "\n"; 

}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 83 ms 6644 KB Output is correct
2 Correct 83 ms 6532 KB Output is correct
3 Correct 84 ms 6648 KB Output is correct
4 Correct 83 ms 6648 KB Output is correct
5 Incorrect 62 ms 6648 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1912 KB Output is correct
2 Correct 20 ms 1916 KB Output is correct
3 Correct 20 ms 1912 KB Output is correct
4 Correct 17 ms 1912 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 17 ms 1912 KB Output is correct
7 Correct 18 ms 1912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 3528 KB Output is correct
2 Correct 37 ms 3448 KB Output is correct
3 Correct 82 ms 6636 KB Output is correct
4 Correct 85 ms 6648 KB Output is correct
5 Correct 32 ms 3448 KB Output is correct
6 Correct 54 ms 6340 KB Output is correct
7 Correct 60 ms 6264 KB Output is correct
8 Correct 33 ms 3448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -