답안 #781982

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
781982 2023-07-13T14:27:42 Z aaron_dcoder Global Warming (CEOI18_glo) C++17
100 / 100
100 ms 8496 KB
#define NDEBUG

#ifdef NDEBUG
#define dbg(TXTMSG) (static_cast<int>(0))
#define dbgv(VARN) (static_cast<int>(0))
#else 
#define dbg(TXTMSG) cerr << "\n" << TXTMSG
#define dbgv(VARN) cerr << "\n" << #VARN << " = "<<VARN << ", line: " << __LINE__ << "\n"
#define _GLIBCXX_DEBUG 1
#define _GLIBCXX_DEBUG_PEDANTIC 1
#endif

#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
constexpr ll INFTY = 1e10;
#define var const auto&

int main() {
    ll N,X;
    cin >> N >> X;

    vector<ll> tempratures(N);

    for (ll i = 0; i < N; i++)
    {
        cin >> tempratures[i];
    }

    vector<ll> needed_info(N);
    vector<ll> currtime_best_revLDS_of_len(N+2,INFTY);
    currtime_best_revLDS_of_len[0] = -INFTY;
    
    for (ll i = (N-1); i >= 0; i--)
    {
        //

        //dbg("array at step") << i;
 
        //for (ll i = 0; i <= N+1; i++)
        {
        //    dbg(":") << (currtime_best_revLDS_of_len[i]);
        }

        //dbgv(*lower_bound(currtime_best_revLDS_of_len.begin(),currtime_best_revLDS_of_len.end(), -(tempratures[i]-X)));

        needed_info[i] = lower_bound(currtime_best_revLDS_of_len.begin(),currtime_best_revLDS_of_len.end(), -(tempratures[i]-X)) 
        - currtime_best_revLDS_of_len.begin()-1ll;
        dbgv(needed_info[i]);
        //

        ll cindice = lower_bound(currtime_best_revLDS_of_len.begin(),currtime_best_revLDS_of_len.end()
        , -tempratures[i]) 
        - currtime_best_revLDS_of_len.begin();
        
        
        currtime_best_revLDS_of_len[cindice]=-tempratures[i];

        
    }





    vector<ll> before_cheating_best_LIS_of_len(N+1,INFTY);
    before_cheating_best_LIS_of_len[0]=-INFTY;

    ll best = 1;

    for (ll i = 0; i < N; i++)
    {
        //dbg("array 2 at step") << i;
 
        //for (ll i = 0; i < N; i++)
        {
        //    dbg(":") << (before_cheating_best_LIS_of_len[i]);
        }


        best = max(best,
        needed_info[i]
        + (lower_bound(before_cheating_best_LIS_of_len.begin(),before_cheating_best_LIS_of_len.end(), tempratures[i]) - before_cheating_best_LIS_of_len.begin())
        );

        *lower_bound(before_cheating_best_LIS_of_len.begin(),before_cheating_best_LIS_of_len.end(), tempratures[i])
        =tempratures[i];

    
    }


    cout << max(best,lower_bound(before_cheating_best_LIS_of_len.begin(),before_cheating_best_LIS_of_len.end(), INFTY) 
        - before_cheating_best_LIS_of_len.begin()-1ll);    
    
}
/*
6 10
6 5 4 3 2 1*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 1 ms 300 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 224 KB Output is correct
11 Correct 0 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 1 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 1 ms 300 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 224 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 300 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 304 KB Output is correct
18 Correct 0 ms 300 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 1 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 1 ms 300 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 224 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 300 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 304 KB Output is correct
18 Correct 0 ms 300 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 1 ms 308 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 304 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 8004 KB Output is correct
2 Correct 100 ms 8088 KB Output is correct
3 Correct 100 ms 8080 KB Output is correct
4 Correct 99 ms 8016 KB Output is correct
5 Correct 70 ms 7372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 2260 KB Output is correct
2 Correct 25 ms 2336 KB Output is correct
3 Correct 24 ms 2260 KB Output is correct
4 Correct 18 ms 2144 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 18 ms 2156 KB Output is correct
7 Correct 21 ms 2340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 4228 KB Output is correct
2 Correct 46 ms 4224 KB Output is correct
3 Correct 92 ms 8088 KB Output is correct
4 Correct 68 ms 7404 KB Output is correct
5 Correct 37 ms 3924 KB Output is correct
6 Correct 62 ms 7104 KB Output is correct
7 Correct 79 ms 8008 KB Output is correct
8 Correct 41 ms 4300 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 1 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 1 ms 300 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 224 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 300 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 304 KB Output is correct
18 Correct 0 ms 300 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 1 ms 308 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 304 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 99 ms 8004 KB Output is correct
28 Correct 100 ms 8088 KB Output is correct
29 Correct 100 ms 8080 KB Output is correct
30 Correct 99 ms 8016 KB Output is correct
31 Correct 70 ms 7372 KB Output is correct
32 Correct 24 ms 2260 KB Output is correct
33 Correct 25 ms 2336 KB Output is correct
34 Correct 24 ms 2260 KB Output is correct
35 Correct 18 ms 2144 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 18 ms 2156 KB Output is correct
38 Correct 21 ms 2340 KB Output is correct
39 Correct 46 ms 4228 KB Output is correct
40 Correct 46 ms 4224 KB Output is correct
41 Correct 92 ms 8088 KB Output is correct
42 Correct 68 ms 7404 KB Output is correct
43 Correct 37 ms 3924 KB Output is correct
44 Correct 62 ms 7104 KB Output is correct
45 Correct 79 ms 8008 KB Output is correct
46 Correct 41 ms 4300 KB Output is correct
47 Correct 49 ms 4400 KB Output is correct
48 Correct 49 ms 4340 KB Output is correct
49 Correct 98 ms 8380 KB Output is correct
50 Correct 68 ms 7608 KB Output is correct
51 Correct 53 ms 5812 KB Output is correct
52 Correct 71 ms 7724 KB Output is correct
53 Correct 64 ms 7740 KB Output is correct
54 Correct 78 ms 8416 KB Output is correct
55 Correct 87 ms 8496 KB Output is correct