답안 #1103979

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1103979 2024-10-22T14:06:04 Z vjudge1 Global Warming (CEOI18_glo) C++17
100 / 100
39 ms 4688 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int a[200200], dp[200200], l[202100];
void solve() {
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    for (int i = 1;i <= n;i++) {
        cin >> a[i];
        int idx = lower_bound(dp, dp + cnt, a[i]) - dp;
        if (idx == cnt) cnt++;
        dp[idx] = a[i];
        l[i] = idx + 1;
    }
    int mx = cnt;
    cnt = 0;
    for (int i = n;i >= 1;i--) {
        int idx = lower_bound(dp, dp + cnt, -a[i]) - dp;
        mx = max(mx, l[i] + idx);
        idx = lower_bound(dp, dp + cnt, -(a[i] + k)) - dp;
        if (idx == cnt) cnt++;
        dp[idx] = -(a[i] + k);
    }
    cout << mx << '\n';
}

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int q = 1;
    while (q--) {
        solve();
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2516 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2516 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 2 ms 2384 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 2 ms 2620 KB Output is correct
24 Correct 2 ms 2384 KB Output is correct
25 Correct 1 ms 2384 KB Output is correct
26 Correct 1 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 2808 KB Output is correct
2 Correct 39 ms 3308 KB Output is correct
3 Correct 39 ms 2640 KB Output is correct
4 Correct 38 ms 2640 KB Output is correct
5 Correct 24 ms 3480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 3152 KB Output is correct
2 Correct 11 ms 3044 KB Output is correct
3 Correct 10 ms 2640 KB Output is correct
4 Correct 7 ms 2896 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 6 ms 2896 KB Output is correct
7 Correct 9 ms 3152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 3408 KB Output is correct
2 Correct 17 ms 3664 KB Output is correct
3 Correct 37 ms 4688 KB Output is correct
4 Correct 23 ms 3984 KB Output is correct
5 Correct 12 ms 3152 KB Output is correct
6 Correct 19 ms 3912 KB Output is correct
7 Correct 24 ms 4432 KB Output is correct
8 Correct 15 ms 2640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2516 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 2 ms 2384 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 2 ms 2620 KB Output is correct
24 Correct 2 ms 2384 KB Output is correct
25 Correct 1 ms 2384 KB Output is correct
26 Correct 1 ms 2384 KB Output is correct
27 Correct 39 ms 2808 KB Output is correct
28 Correct 39 ms 3308 KB Output is correct
29 Correct 39 ms 2640 KB Output is correct
30 Correct 38 ms 2640 KB Output is correct
31 Correct 24 ms 3480 KB Output is correct
32 Correct 10 ms 3152 KB Output is correct
33 Correct 11 ms 3044 KB Output is correct
34 Correct 10 ms 2640 KB Output is correct
35 Correct 7 ms 2896 KB Output is correct
36 Correct 1 ms 2384 KB Output is correct
37 Correct 6 ms 2896 KB Output is correct
38 Correct 9 ms 3152 KB Output is correct
39 Correct 19 ms 3408 KB Output is correct
40 Correct 17 ms 3664 KB Output is correct
41 Correct 37 ms 4688 KB Output is correct
42 Correct 23 ms 3984 KB Output is correct
43 Correct 12 ms 3152 KB Output is correct
44 Correct 19 ms 3912 KB Output is correct
45 Correct 24 ms 4432 KB Output is correct
46 Correct 15 ms 2640 KB Output is correct
47 Correct 20 ms 2640 KB Output is correct
48 Correct 20 ms 3664 KB Output is correct
49 Correct 39 ms 4420 KB Output is correct
50 Correct 29 ms 3960 KB Output is correct
51 Correct 22 ms 3664 KB Output is correct
52 Correct 23 ms 3920 KB Output is correct
53 Correct 20 ms 3920 KB Output is correct
54 Correct 24 ms 4508 KB Output is correct
55 Correct 32 ms 4680 KB Output is correct