답안 #1101949

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1101949 2024-10-17T08:34:37 Z Tame Global Warming (CEOI18_glo) C++14
100 / 100
44 ms 3536 KB
#include <bits/stdc++.h>
#define pu push
#define pf push_front
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define el cout<<"\n"
#define ll long long
#define ld long double
#define MASK(i) (1LL<<(i))
#define BIT(x, i) (((x)>>(i))&1)
#define SET_OFF(x, i) ((x)&~MASK(i))
#define SET_ON(x, i) ((x)|MASK(i))
#define c_bit(i) __builtin_popcount(i)
const int MAX_SIZE = 200100;
const int inf = (int)1e9+7;
using namespace std;

template<class T1, class T2>
    bool maximize(T1 &x, T2 y){if(x<y){x=y; return true;} return false;}
template<class T1, class T2>
    bool minimize(T1 &x, T2 y){if(x>y){x=y; return true;} return false;}

int nLength, nDist, res=0;
int a[MAX_SIZE], Left[MAX_SIZE], Right[MAX_SIZE];
vector<int>dp;

void init(){
    cin>>nLength>>nDist;
    for (int i=0; i<nLength; i++){
        cin>>a[i];
    }
}

void ilovesunshine(){
    init();

    //find left
    dp.assign(nLength, inf);
    for (int i=0; i<nLength; i++){
        int j = lower_bound(dp.begin(), dp.end(), a[i])-dp.begin(); dp[j]=a[i];
        Left[i]=j+1; maximize(res, Left[i]);
    }
    //find right
    dp.assign(nLength, inf);
    for (int i=nLength-1; i>=0; i--){
        int j = lower_bound(dp.begin(), dp.end(), -a[i]+nDist)-dp.begin();
        Right[i]=j;
        int tmp = lower_bound(dp.begin(), dp.end(), -a[i]) - dp.begin(); dp[tmp]=-a[i];
    }
    for (int i=0; i<nLength; i++) maximize(res, Left[i]+Right[i]);
    cout<<res;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//    freopen("APEN.INP", "r", stdin);
//    freopen("APEN.OUT", "w", stdout);
    ilovesunshine();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2516 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 1 ms 2552 KB Output is correct
24 Correct 1 ms 2384 KB Output is correct
25 Correct 1 ms 2384 KB Output is correct
26 Correct 1 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 3420 KB Output is correct
2 Correct 39 ms 3408 KB Output is correct
3 Correct 39 ms 3416 KB Output is correct
4 Correct 41 ms 3408 KB Output is correct
5 Correct 27 ms 3408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 2896 KB Output is correct
2 Correct 9 ms 2720 KB Output is correct
3 Correct 9 ms 2640 KB Output is correct
4 Correct 7 ms 2640 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 8 ms 2700 KB Output is correct
7 Correct 8 ms 2776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 2896 KB Output is correct
2 Correct 18 ms 2896 KB Output is correct
3 Correct 36 ms 3532 KB Output is correct
4 Correct 38 ms 3408 KB Output is correct
5 Correct 15 ms 2896 KB Output is correct
6 Correct 25 ms 3420 KB Output is correct
7 Correct 28 ms 3412 KB Output is correct
8 Correct 15 ms 2896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2516 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 1 ms 2552 KB Output is correct
24 Correct 1 ms 2384 KB Output is correct
25 Correct 1 ms 2384 KB Output is correct
26 Correct 1 ms 2384 KB Output is correct
27 Correct 39 ms 3420 KB Output is correct
28 Correct 39 ms 3408 KB Output is correct
29 Correct 39 ms 3416 KB Output is correct
30 Correct 41 ms 3408 KB Output is correct
31 Correct 27 ms 3408 KB Output is correct
32 Correct 9 ms 2896 KB Output is correct
33 Correct 9 ms 2720 KB Output is correct
34 Correct 9 ms 2640 KB Output is correct
35 Correct 7 ms 2640 KB Output is correct
36 Correct 1 ms 2384 KB Output is correct
37 Correct 8 ms 2700 KB Output is correct
38 Correct 8 ms 2776 KB Output is correct
39 Correct 18 ms 2896 KB Output is correct
40 Correct 18 ms 2896 KB Output is correct
41 Correct 36 ms 3532 KB Output is correct
42 Correct 38 ms 3408 KB Output is correct
43 Correct 15 ms 2896 KB Output is correct
44 Correct 25 ms 3420 KB Output is correct
45 Correct 28 ms 3412 KB Output is correct
46 Correct 15 ms 2896 KB Output is correct
47 Correct 19 ms 2896 KB Output is correct
48 Correct 19 ms 2896 KB Output is correct
49 Correct 44 ms 3408 KB Output is correct
50 Correct 28 ms 3420 KB Output is correct
51 Correct 26 ms 3152 KB Output is correct
52 Correct 31 ms 3536 KB Output is correct
53 Correct 26 ms 3408 KB Output is correct
54 Correct 29 ms 3408 KB Output is correct
55 Correct 31 ms 3408 KB Output is correct