Submission #533725

# Submission time Handle Problem Language Result Execution time Memory
533725 2022-03-07T04:29:43 Z Sharky Global Warming (CEOI18_glo) C++17
100 / 100
57 ms 8516 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int inf = 1e18;
signed main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, x; cin >> n >> x;
    vector<int> a(n), L(n), R(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> dp(n, inf);
    int mx = 0;
    for (int i = 0; i < n; i++) {
        int j = lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin();
        dp[j] = a[i];
        L[i] = j + 1;
    }
    fill(dp.begin(), dp.end(), inf);
    for (int i = n - 1; i >= 0; i--) {
        int pos = lower_bound(dp.begin(), dp.end(), -(a[i] - x)) - dp.begin();
        R[i] = pos;
        pos = lower_bound(dp.begin(), dp.end(), -a[i]) - dp.begin();
        dp[pos] = -a[i];
    }
    for (int i = 0; i < n; i++) {
        mx = max(mx, L[i] + R[i]);
    }
    cout << mx << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 316 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 8452 KB Output is correct
2 Correct 57 ms 8448 KB Output is correct
3 Correct 55 ms 8448 KB Output is correct
4 Correct 53 ms 8376 KB Output is correct
5 Correct 41 ms 7860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 2380 KB Output is correct
2 Correct 13 ms 2236 KB Output is correct
3 Correct 12 ms 2232 KB Output is correct
4 Correct 11 ms 2112 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 10 ms 2116 KB Output is correct
7 Correct 12 ms 2368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 4312 KB Output is correct
2 Correct 27 ms 4292 KB Output is correct
3 Correct 50 ms 8516 KB Output is correct
4 Correct 40 ms 7688 KB Output is correct
5 Correct 20 ms 4032 KB Output is correct
6 Correct 35 ms 7332 KB Output is correct
7 Correct 40 ms 8100 KB Output is correct
8 Correct 21 ms 4412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 316 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 53 ms 8452 KB Output is correct
28 Correct 57 ms 8448 KB Output is correct
29 Correct 55 ms 8448 KB Output is correct
30 Correct 53 ms 8376 KB Output is correct
31 Correct 41 ms 7860 KB Output is correct
32 Correct 14 ms 2380 KB Output is correct
33 Correct 13 ms 2236 KB Output is correct
34 Correct 12 ms 2232 KB Output is correct
35 Correct 11 ms 2112 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 10 ms 2116 KB Output is correct
38 Correct 12 ms 2368 KB Output is correct
39 Correct 24 ms 4312 KB Output is correct
40 Correct 27 ms 4292 KB Output is correct
41 Correct 50 ms 8516 KB Output is correct
42 Correct 40 ms 7688 KB Output is correct
43 Correct 20 ms 4032 KB Output is correct
44 Correct 35 ms 7332 KB Output is correct
45 Correct 40 ms 8100 KB Output is correct
46 Correct 21 ms 4412 KB Output is correct
47 Correct 27 ms 4304 KB Output is correct
48 Correct 27 ms 4304 KB Output is correct
49 Correct 52 ms 8388 KB Output is correct
50 Correct 46 ms 7684 KB Output is correct
51 Correct 34 ms 5856 KB Output is correct
52 Correct 42 ms 7816 KB Output is correct
53 Correct 39 ms 7788 KB Output is correct
54 Correct 41 ms 8508 KB Output is correct
55 Correct 48 ms 8516 KB Output is correct