답안 #230129

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
230129 2020-05-08T16:45:17 Z DodgeBallMan Global Warming (CEOI18_glo) C++14
100 / 100
77 ms 8568 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 = lower_bound(lis, lis + N + 1, A[i]) - lis;
        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 = upper_bound(lds, lds + N + 1, A[i]) - lds - 1;
        lds[j] = 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"; 
 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 8568 KB Output is correct
2 Correct 73 ms 8440 KB Output is correct
3 Correct 75 ms 8568 KB Output is correct
4 Correct 76 ms 8568 KB Output is correct
5 Correct 56 ms 7800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 2432 KB Output is correct
2 Correct 21 ms 2432 KB Output is correct
3 Correct 21 ms 2432 KB Output is correct
4 Correct 18 ms 2176 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 18 ms 2176 KB Output is correct
7 Correct 19 ms 2432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 4472 KB Output is correct
2 Correct 36 ms 4472 KB Output is correct
3 Correct 71 ms 8568 KB Output is correct
4 Correct 55 ms 7808 KB Output is correct
5 Correct 33 ms 4096 KB Output is correct
6 Correct 50 ms 7416 KB Output is correct
7 Correct 57 ms 8184 KB Output is correct
8 Correct 33 ms 4480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 77 ms 8568 KB Output is correct
28 Correct 73 ms 8440 KB Output is correct
29 Correct 75 ms 8568 KB Output is correct
30 Correct 76 ms 8568 KB Output is correct
31 Correct 56 ms 7800 KB Output is correct
32 Correct 20 ms 2432 KB Output is correct
33 Correct 21 ms 2432 KB Output is correct
34 Correct 21 ms 2432 KB Output is correct
35 Correct 18 ms 2176 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
37 Correct 18 ms 2176 KB Output is correct
38 Correct 19 ms 2432 KB Output is correct
39 Correct 36 ms 4472 KB Output is correct
40 Correct 36 ms 4472 KB Output is correct
41 Correct 71 ms 8568 KB Output is correct
42 Correct 55 ms 7808 KB Output is correct
43 Correct 33 ms 4096 KB Output is correct
44 Correct 50 ms 7416 KB Output is correct
45 Correct 57 ms 8184 KB Output is correct
46 Correct 33 ms 4480 KB Output is correct
47 Correct 38 ms 4472 KB Output is correct
48 Correct 38 ms 4480 KB Output is correct
49 Correct 76 ms 8440 KB Output is correct
50 Correct 57 ms 7800 KB Output is correct
51 Correct 45 ms 5880 KB Output is correct
52 Correct 57 ms 7936 KB Output is correct
53 Correct 54 ms 7800 KB Output is correct
54 Correct 61 ms 8568 KB Output is correct
55 Correct 65 ms 8568 KB Output is correct