답안 #575912

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
575912 2022-06-11T16:29:02 Z teki Global Warming (CEOI18_glo) C++11
100 / 100
54 ms 4596 KB
#include <bits/stdc++.h>

typedef long long ll;

#define pb push_back
#define MS(x,y) memset((x),(y),sizeof((x)))
#define MN 1000000007

using namespace std;

int main()
{
    #if LOCAL_DEBUG
        fstream cin("in.txt");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,x;
    cin>>n>>x;

    int niza[n];
    for (int i = 0; i<n; i++) cin>>niza[i];

    int dp[n], lisPref[n];
    for (int i = 0; i<n; i++) dp[i] = INT_MAX/2;
    int res = 0;

    for (int i = 0; i<n; i++) {
        auto sled = lower_bound(dp,dp+n,niza[i]);
        int j = sled-dp;
        dp[j] = niza[i];
        lisPref[i] = j+1;

        res = max(res,lisPref[i]);
    }

    for (int i = 0; i<n; i++) dp[i] = INT_MAX/2;

    for (int i = n-1; i>=0; i--) {
        auto prev = lower_bound(dp,dp+n,-niza[i]+x);
        int j = prev-dp;

        res = max(res,lisPref[i]+j);

        auto ide = lower_bound(dp,dp+n,-niza[i]);
        int idePos = ide-dp;

        dp[idePos] = -niza[i];
    }

    cout<<res<<endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 324 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 324 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 320 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 316 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 324 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 320 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 316 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 328 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 324 KB Output is correct
24 Correct 1 ms 320 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 4564 KB Output is correct
2 Correct 53 ms 4516 KB Output is correct
3 Correct 54 ms 4572 KB Output is correct
4 Correct 52 ms 4532 KB Output is correct
5 Correct 45 ms 3772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 1384 KB Output is correct
2 Correct 13 ms 1364 KB Output is correct
3 Correct 12 ms 1380 KB Output is correct
4 Correct 10 ms 1100 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 10 ms 1192 KB Output is correct
7 Correct 11 ms 1364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 2352 KB Output is correct
2 Correct 26 ms 2352 KB Output is correct
3 Correct 49 ms 4516 KB Output is correct
4 Correct 42 ms 3796 KB Output is correct
5 Correct 20 ms 2000 KB Output is correct
6 Correct 32 ms 3732 KB Output is correct
7 Correct 37 ms 4384 KB Output is correct
8 Correct 20 ms 2448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 324 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 320 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 316 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 328 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 324 KB Output is correct
24 Correct 1 ms 320 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 320 KB Output is correct
27 Correct 54 ms 4564 KB Output is correct
28 Correct 53 ms 4516 KB Output is correct
29 Correct 54 ms 4572 KB Output is correct
30 Correct 52 ms 4532 KB Output is correct
31 Correct 45 ms 3772 KB Output is correct
32 Correct 13 ms 1384 KB Output is correct
33 Correct 13 ms 1364 KB Output is correct
34 Correct 12 ms 1380 KB Output is correct
35 Correct 10 ms 1100 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 10 ms 1192 KB Output is correct
38 Correct 11 ms 1364 KB Output is correct
39 Correct 25 ms 2352 KB Output is correct
40 Correct 26 ms 2352 KB Output is correct
41 Correct 49 ms 4516 KB Output is correct
42 Correct 42 ms 3796 KB Output is correct
43 Correct 20 ms 2000 KB Output is correct
44 Correct 32 ms 3732 KB Output is correct
45 Correct 37 ms 4384 KB Output is correct
46 Correct 20 ms 2448 KB Output is correct
47 Correct 26 ms 2352 KB Output is correct
48 Correct 25 ms 2436 KB Output is correct
49 Correct 54 ms 4568 KB Output is correct
50 Correct 44 ms 3768 KB Output is correct
51 Correct 29 ms 2892 KB Output is correct
52 Correct 40 ms 3924 KB Output is correct
53 Correct 33 ms 3780 KB Output is correct
54 Correct 39 ms 4596 KB Output is correct
55 Correct 43 ms 4584 KB Output is correct