Submission #433395

# Submission time Handle Problem Language Result Execution time Memory
433395 2021-06-19T16:49:11 Z fvogel499 Global Warming (CEOI18_glo) C++14
100 / 100
125 ms 8484 KB
/*
File created on 06/19/2021 at 18:39:52.
Link to problem: https://oj.uz/problem/view/CEOI18_glo
Description: 
Time complexity: O()
Space complexity: O()
Status: DEV
Copyright: Ⓒ 2021 Francois Vogel
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

#define pii pair<int, int>
#define f first
#define s second

#define pb push_back
#define ins insert
#define cls clear

#define int ll
#define ll long long

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int inf = 1e18;

signed main() {
    cin.tie(0);
    // ios_base::sync_with_stdio(0);

    int n, x;
    cin >> n >> x;
    int b [n];
    for (int i = 0; i < n; i++) cin >> b[i];
    vector<int> dp(n, inf);
    int mxv = 0;
    int lp [n];
    for (int i = 0; i < n; i++) {
        int j = lower_bound(dp.begin(), dp.end(), b[i])-dp.begin();
        lp[i] = j+1;
        mxv = max(mxv, lp[i]);
        dp[j] = b[i];
    }
    for (int i = 0; i < n; i++) b[i] *= -1;
    dp = vector<int>(n, inf);
    for (int i = n-1; i >= 0; i--) {
        int useful = lower_bound(dp.begin(), dp.end(), b[i]+x)-dp.begin();
        mxv = max(mxv, lp[i]+useful);
        int j = lower_bound(dp.begin(), dp.end(), b[i])-dp.begin();
        dp[j] = b[i];
    }
    cout << mxv;

    int d = 0;
    d++;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 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 0 ms 292 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 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 0 ms 292 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 288 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 292 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 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 0 ms 292 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 288 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 292 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 296 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 292 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 121 ms 6436 KB Output is correct
2 Correct 125 ms 8464 KB Output is correct
3 Correct 118 ms 8356 KB Output is correct
4 Correct 118 ms 8344 KB Output is correct
5 Correct 82 ms 7588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 1732 KB Output is correct
2 Correct 32 ms 2304 KB Output is correct
3 Correct 30 ms 2332 KB Output is correct
4 Correct 21 ms 2120 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 22 ms 2116 KB Output is correct
7 Correct 27 ms 2252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 3360 KB Output is correct
2 Correct 73 ms 4296 KB Output is correct
3 Correct 113 ms 8472 KB Output is correct
4 Correct 83 ms 7716 KB Output is correct
5 Correct 43 ms 3932 KB Output is correct
6 Correct 77 ms 7388 KB Output is correct
7 Correct 99 ms 8020 KB Output is correct
8 Correct 52 ms 4376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 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 0 ms 292 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 288 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 292 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 296 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 292 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 288 KB Output is correct
27 Correct 121 ms 6436 KB Output is correct
28 Correct 125 ms 8464 KB Output is correct
29 Correct 118 ms 8356 KB Output is correct
30 Correct 118 ms 8344 KB Output is correct
31 Correct 82 ms 7588 KB Output is correct
32 Correct 40 ms 1732 KB Output is correct
33 Correct 32 ms 2304 KB Output is correct
34 Correct 30 ms 2332 KB Output is correct
35 Correct 21 ms 2120 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 22 ms 2116 KB Output is correct
38 Correct 27 ms 2252 KB Output is correct
39 Correct 56 ms 3360 KB Output is correct
40 Correct 73 ms 4296 KB Output is correct
41 Correct 113 ms 8472 KB Output is correct
42 Correct 83 ms 7716 KB Output is correct
43 Correct 43 ms 3932 KB Output is correct
44 Correct 77 ms 7388 KB Output is correct
45 Correct 99 ms 8020 KB Output is correct
46 Correct 52 ms 4376 KB Output is correct
47 Correct 61 ms 4364 KB Output is correct
48 Correct 58 ms 4368 KB Output is correct
49 Correct 120 ms 8360 KB Output is correct
50 Correct 81 ms 7592 KB Output is correct
51 Correct 68 ms 5792 KB Output is correct
52 Correct 97 ms 7720 KB Output is correct
53 Correct 83 ms 7748 KB Output is correct
54 Correct 104 ms 8472 KB Output is correct
55 Correct 119 ms 8484 KB Output is correct