답안 #328367

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
328367 2020-11-16T09:58:15 Z Sara Global Warming (CEOI18_glo) C++14
100 / 100
131 ms 2796 KB
#include <bits/stdc++.h>
     
using namespace std;
     
#define ll long long int 
#define F first
#define S second
#define pb push_back

const ll N = 2e5 + 10;
const ll M = 50;
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 10;
int n, X, a[N], l[N], r[N], f[N], ans;
int main() {
    cin >> n >> X;
    int len = 0;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        int p = lower_bound(l, l + len, a[i]) - l;
        l[p] = a[i];
        len = max(len, p + 1);
        f[i] = p + 1;
    }
    ans = f[n - 1];
    len = 0;
    for (int i = n - 1; i >= 0; i--){
        a[i] *= -1;
        int p = upper_bound(r, r + len, a[i] - 1) - r;
        ans = max(ans, f[i] + p);
        a[i] -= X;
        p = lower_bound(r, r + len, a[i]) - r;
        r[p] = a[i];
        len = max(len, p + 1);
    }
    cout << ans << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 0 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 0 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 131 ms 1952 KB Output is correct
2 Correct 121 ms 1900 KB Output is correct
3 Correct 116 ms 1900 KB Output is correct
4 Correct 125 ms 1900 KB Output is correct
5 Correct 74 ms 2688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 748 KB Output is correct
2 Correct 29 ms 748 KB Output is correct
3 Correct 30 ms 748 KB Output is correct
4 Correct 19 ms 876 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 18 ms 876 KB Output is correct
7 Correct 26 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 1132 KB Output is correct
2 Correct 53 ms 1260 KB Output is correct
3 Correct 109 ms 1900 KB Output is correct
4 Correct 73 ms 2668 KB Output is correct
5 Correct 36 ms 1516 KB Output is correct
6 Correct 68 ms 2540 KB Output is correct
7 Correct 89 ms 2540 KB Output is correct
8 Correct 51 ms 1132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 0 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 131 ms 1952 KB Output is correct
28 Correct 121 ms 1900 KB Output is correct
29 Correct 116 ms 1900 KB Output is correct
30 Correct 125 ms 1900 KB Output is correct
31 Correct 74 ms 2688 KB Output is correct
32 Correct 28 ms 748 KB Output is correct
33 Correct 29 ms 748 KB Output is correct
34 Correct 30 ms 748 KB Output is correct
35 Correct 19 ms 876 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 18 ms 876 KB Output is correct
38 Correct 26 ms 748 KB Output is correct
39 Correct 53 ms 1132 KB Output is correct
40 Correct 53 ms 1260 KB Output is correct
41 Correct 109 ms 1900 KB Output is correct
42 Correct 73 ms 2668 KB Output is correct
43 Correct 36 ms 1516 KB Output is correct
44 Correct 68 ms 2540 KB Output is correct
45 Correct 89 ms 2540 KB Output is correct
46 Correct 51 ms 1132 KB Output is correct
47 Correct 58 ms 1132 KB Output is correct
48 Correct 58 ms 1132 KB Output is correct
49 Correct 117 ms 1956 KB Output is correct
50 Correct 73 ms 2668 KB Output is correct
51 Correct 57 ms 2284 KB Output is correct
52 Correct 76 ms 2668 KB Output is correct
53 Correct 73 ms 2796 KB Output is correct
54 Correct 96 ms 2668 KB Output is correct
55 Correct 106 ms 1900 KB Output is correct