Submission #1085515

# Submission time Handle Problem Language Result Execution time Memory
1085515 2024-09-08T11:15:10 Z vjudge1 Global Warming (CEOI18_glo) C++17
100 / 100
95 ms 11808 KB
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define int long long
#define ar array


const int N = 2e5 + 20;

namespace fewwy{
    int bit[2][N];
    template<int x>
    int qry(int i){
        int ans = 0;
        for(i++;i;i -= i & -i)ans = max(ans,bit[x][i]);
        return ans;
    }

    template<int x>
    void upd(int i,int v){
        for(i++;i < N;i += i & -i)bit[x][i] = max(bit[x][i], v);
    }
}

vector<int> v;
int get(int x){
    return lower_bound(v.begin(), v.end(), x) - v.begin() + 1;
}

signed main() {ios_base::sync_with_stdio(false);cin.tie(0);
    int n, x;
    cin>>n>>x;
    int A[n];
    for(int i =0 ;i < n;i++){
        cin>>A[i];
        v.push_back(A[i]);
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    int ans = 0;
    int dp[n][2];
    for(int i = 0;i < n;i++){
        int y = get(A[i]);
        dp[i][0] = fewwy::qry<0>(y - 1) + 1;
        dp[i][1] = max(fewwy::qry<1>(y - 1), fewwy::qry<0>(get(A[i] + x) - 1)) + 1;
        fewwy::upd<0>(y, dp[i][0]);
        fewwy::upd<1>(y, dp[i][1]);
        ans = max({ans, dp[i][0], dp[i][1]});
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 412 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 412 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 600 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 92 ms 11808 KB Output is correct
2 Correct 90 ms 11720 KB Output is correct
3 Correct 95 ms 11724 KB Output is correct
4 Correct 89 ms 11724 KB Output is correct
5 Correct 39 ms 9584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 3288 KB Output is correct
2 Correct 21 ms 3292 KB Output is correct
3 Correct 20 ms 3292 KB Output is correct
4 Correct 11 ms 2856 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 9 ms 2872 KB Output is correct
7 Correct 16 ms 3436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 6104 KB Output is correct
2 Correct 35 ms 6228 KB Output is correct
3 Correct 85 ms 11724 KB Output is correct
4 Correct 41 ms 9412 KB Output is correct
5 Correct 22 ms 5836 KB Output is correct
6 Correct 41 ms 10708 KB Output is correct
7 Correct 60 ms 11320 KB Output is correct
8 Correct 29 ms 6104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 412 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 600 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 92 ms 11808 KB Output is correct
28 Correct 90 ms 11720 KB Output is correct
29 Correct 95 ms 11724 KB Output is correct
30 Correct 89 ms 11724 KB Output is correct
31 Correct 39 ms 9584 KB Output is correct
32 Correct 20 ms 3288 KB Output is correct
33 Correct 21 ms 3292 KB Output is correct
34 Correct 20 ms 3292 KB Output is correct
35 Correct 11 ms 2856 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 9 ms 2872 KB Output is correct
38 Correct 16 ms 3436 KB Output is correct
39 Correct 39 ms 6104 KB Output is correct
40 Correct 35 ms 6228 KB Output is correct
41 Correct 85 ms 11724 KB Output is correct
42 Correct 41 ms 9412 KB Output is correct
43 Correct 22 ms 5836 KB Output is correct
44 Correct 41 ms 10708 KB Output is correct
45 Correct 60 ms 11320 KB Output is correct
46 Correct 29 ms 6104 KB Output is correct
47 Correct 44 ms 6104 KB Output is correct
48 Correct 43 ms 6104 KB Output is correct
49 Correct 89 ms 11732 KB Output is correct
50 Correct 40 ms 9416 KB Output is correct
51 Correct 37 ms 7628 KB Output is correct
52 Correct 49 ms 11204 KB Output is correct
53 Correct 39 ms 11208 KB Output is correct
54 Correct 41 ms 11716 KB Output is correct
55 Correct 75 ms 11792 KB Output is correct