Submission #141208

# Submission time Handle Problem Language Result Execution time Memory
141208 2019-08-07T06:41:39 Z meatrow Global Warming (CEOI18_glo) C++17
100 / 100
78 ms 5496 KB
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, x;
    cin >> n >> x;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        b[n - i - 1] = -a[i];
    }
    vector<int> t(n + 1, INT32_MAX);
    t[0] = INT32_MIN;
    vector<int> lds(n);
    for (int i = 0; i < n; ++i) {
        lds[i] = lower_bound(t.begin(), t.end(), b[i]) - t.begin();
        t[lds[i]] = min(t[lds[i]], b[i]);
    }
    t.assign(n + 1, INT32_MAX);
    t[0] = INT32_MIN;
    int ans = 1;
    for (int i = 0; i + 1 < n; ++i) {
        int kek = lower_bound(t.begin(), t.end(), a[i]) - t.begin();
        t[kek] = min(t[kek], a[i]);
        ans = max(ans, kek);
        int pos = lower_bound(t.begin(), t.end(), a[i + 1] + x) - t.begin() - 1;
        ans = max(ans, pos + lds[n - i - 2]);
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 424 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 412 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 424 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 412 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 380 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 424 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 412 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 380 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 2 ms 348 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 392 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 78 ms 5472 KB Output is correct
2 Correct 78 ms 5496 KB Output is correct
3 Correct 78 ms 5464 KB Output is correct
4 Correct 77 ms 5404 KB Output is correct
5 Correct 56 ms 4636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 1660 KB Output is correct
2 Correct 19 ms 1656 KB Output is correct
3 Correct 19 ms 1628 KB Output is correct
4 Correct 15 ms 1408 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 16 ms 1420 KB Output is correct
7 Correct 17 ms 1660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 2824 KB Output is correct
2 Correct 35 ms 2928 KB Output is correct
3 Correct 69 ms 5396 KB Output is correct
4 Correct 60 ms 4700 KB Output is correct
5 Correct 31 ms 2472 KB Output is correct
6 Correct 51 ms 4500 KB Output is correct
7 Correct 58 ms 5324 KB Output is correct
8 Correct 31 ms 2824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 424 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 412 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 380 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 2 ms 348 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 392 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 78 ms 5472 KB Output is correct
28 Correct 78 ms 5496 KB Output is correct
29 Correct 78 ms 5464 KB Output is correct
30 Correct 77 ms 5404 KB Output is correct
31 Correct 56 ms 4636 KB Output is correct
32 Correct 19 ms 1660 KB Output is correct
33 Correct 19 ms 1656 KB Output is correct
34 Correct 19 ms 1628 KB Output is correct
35 Correct 15 ms 1408 KB Output is correct
36 Correct 2 ms 380 KB Output is correct
37 Correct 16 ms 1420 KB Output is correct
38 Correct 17 ms 1660 KB Output is correct
39 Correct 34 ms 2824 KB Output is correct
40 Correct 35 ms 2928 KB Output is correct
41 Correct 69 ms 5396 KB Output is correct
42 Correct 60 ms 4700 KB Output is correct
43 Correct 31 ms 2472 KB Output is correct
44 Correct 51 ms 4500 KB Output is correct
45 Correct 58 ms 5324 KB Output is correct
46 Correct 31 ms 2824 KB Output is correct
47 Correct 39 ms 2940 KB Output is correct
48 Correct 38 ms 2960 KB Output is correct
49 Correct 78 ms 5400 KB Output is correct
50 Correct 56 ms 4688 KB Output is correct
51 Correct 46 ms 3596 KB Output is correct
52 Correct 61 ms 4728 KB Output is correct
53 Correct 53 ms 4816 KB Output is correct
54 Correct 63 ms 5476 KB Output is correct
55 Correct 66 ms 5368 KB Output is correct