답안 #957776

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
957776 2024-04-04T10:08:50 Z LucaIlie Global Warming (CEOI18_glo) C++17
100 / 100
464 ms 24916 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 2e5;

struct AIB {
    int aib[2 * MAX_N + 1];

    void update( int i, int x ) {
        while ( i <= 2 * MAX_N ) {
            aib[i] = max( aib[i], x );
            i += (i & -i);
        }
    }

    int query( int i ) {
        int x = 0;
        while ( i > 0 ) {
            x = max( x, aib[i] );
            i -= (i & -i);
        }
        return x;
    }
} dp0, dp1;

int v[MAX_N + 1];
map<int, int> nrm;

int main() {
    int n, x;

    cin >> n >> x;
    for ( int i = 0; i < n; i++ ) {
        cin >> v[i];
        nrm[v[i]] = 1;
        nrm[v[i] + x] = 1;
    }

    int a = 0;
    for ( auto p: nrm )
        nrm[p.first] = ++a;

    for ( int i = 0; i < n; i++ ) {
        int maxLen0 = dp0.query( nrm[v[i]] - 1 ) + 1, maxLen1 = max( dp0.query( nrm[v[i] + x] - 1 ), dp1.query( nrm[v[i]] - 1 ) ) + 1;
        dp0.update( nrm[v[i]], maxLen0 );
        dp1.update( nrm[v[i]], maxLen1 );
    }

    cout << max( dp0.query( a ), dp1.query( a ) );

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 0 ms 344 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 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 0 ms 344 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 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 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 1 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 0 ms 344 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 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 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 1 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 2 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 600 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 289 ms 12852 KB Output is correct
2 Correct 293 ms 14676 KB Output is correct
3 Correct 273 ms 14676 KB Output is correct
4 Correct 293 ms 14760 KB Output is correct
5 Correct 144 ms 8712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 7720 KB Output is correct
2 Correct 72 ms 7772 KB Output is correct
3 Correct 70 ms 7768 KB Output is correct
4 Correct 34 ms 5204 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 38 ms 5168 KB Output is correct
7 Correct 59 ms 6736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 178 ms 12220 KB Output is correct
2 Correct 173 ms 12224 KB Output is correct
3 Correct 464 ms 22596 KB Output is correct
4 Correct 194 ms 13520 KB Output is correct
5 Correct 132 ms 12880 KB Output is correct
6 Correct 237 ms 22356 KB Output is correct
7 Correct 254 ms 22884 KB Output is correct
8 Correct 143 ms 13416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 0 ms 344 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 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 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 1 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 2 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 600 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 289 ms 12852 KB Output is correct
28 Correct 293 ms 14676 KB Output is correct
29 Correct 273 ms 14676 KB Output is correct
30 Correct 293 ms 14760 KB Output is correct
31 Correct 144 ms 8712 KB Output is correct
32 Correct 76 ms 7720 KB Output is correct
33 Correct 72 ms 7772 KB Output is correct
34 Correct 70 ms 7768 KB Output is correct
35 Correct 34 ms 5204 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 38 ms 5168 KB Output is correct
38 Correct 59 ms 6736 KB Output is correct
39 Correct 178 ms 12220 KB Output is correct
40 Correct 173 ms 12224 KB Output is correct
41 Correct 464 ms 22596 KB Output is correct
42 Correct 194 ms 13520 KB Output is correct
43 Correct 132 ms 12880 KB Output is correct
44 Correct 237 ms 22356 KB Output is correct
45 Correct 254 ms 22884 KB Output is correct
46 Correct 143 ms 13416 KB Output is correct
47 Correct 171 ms 13792 KB Output is correct
48 Correct 158 ms 13648 KB Output is correct
49 Correct 417 ms 24916 KB Output is correct
50 Correct 147 ms 14164 KB Output is correct
51 Correct 142 ms 10836 KB Output is correct
52 Correct 206 ms 13904 KB Output is correct
53 Correct 265 ms 23612 KB Output is correct
54 Correct 268 ms 24148 KB Output is correct
55 Correct 307 ms 21560 KB Output is correct