답안 #538458

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
538458 2022-03-17T02:03:16 Z pokmui9909 Global Warming (CEOI18_glo) C++17
100 / 100
61 ms 6268 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
ll N, X;
ll A[200005], L[200005];
 
int main(){
    cin.tie(0) -> sync_with_stdio(false);
 
    cin >> N >> X;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    vector<ll> dp;
    for(int i = 0; i < N; i++){
        if(dp.empty() || dp.back() < A[i]){
            dp.push_back(A[i]);
            L[i] = dp.size();
        } else {
            ll j = lower_bound(dp.begin(), dp.end(), A[i]) - dp.begin();
            dp[j] = A[i], L[i] = j + 1;
        }
    }
    dp.clear();
    ll ans = 0;
    for(int i = N - 1; i >= 0; i--){
        ans = max(ans, L[i] + (lower_bound(dp.begin(), dp.end(), -A[i] + X) - dp.begin()));
        if(dp.empty() || dp.back() < -A[i]) dp.push_back(-A[i]);
        else *lower_bound(dp.begin(), dp.end(), -A[i]) = -A[i];
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 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 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 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 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 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 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 3448 KB Output is correct
2 Correct 51 ms 3400 KB Output is correct
3 Correct 50 ms 3388 KB Output is correct
4 Correct 49 ms 3404 KB Output is correct
5 Correct 26 ms 4340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 1128 KB Output is correct
2 Correct 12 ms 1088 KB Output is correct
3 Correct 14 ms 1108 KB Output is correct
4 Correct 7 ms 1368 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 6 ms 1368 KB Output is correct
7 Correct 10 ms 1124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 1896 KB Output is correct
2 Correct 21 ms 1876 KB Output is correct
3 Correct 43 ms 3452 KB Output is correct
4 Correct 28 ms 4304 KB Output is correct
5 Correct 12 ms 2340 KB Output is correct
6 Correct 20 ms 4176 KB Output is correct
7 Correct 29 ms 4144 KB Output is correct
8 Correct 18 ms 1908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 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 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 51 ms 3448 KB Output is correct
28 Correct 51 ms 3400 KB Output is correct
29 Correct 50 ms 3388 KB Output is correct
30 Correct 49 ms 3404 KB Output is correct
31 Correct 26 ms 4340 KB Output is correct
32 Correct 12 ms 1128 KB Output is correct
33 Correct 12 ms 1088 KB Output is correct
34 Correct 14 ms 1108 KB Output is correct
35 Correct 7 ms 1368 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 6 ms 1368 KB Output is correct
38 Correct 10 ms 1124 KB Output is correct
39 Correct 20 ms 1896 KB Output is correct
40 Correct 21 ms 1876 KB Output is correct
41 Correct 43 ms 3452 KB Output is correct
42 Correct 28 ms 4304 KB Output is correct
43 Correct 12 ms 2340 KB Output is correct
44 Correct 20 ms 4176 KB Output is correct
45 Correct 29 ms 4144 KB Output is correct
46 Correct 18 ms 1908 KB Output is correct
47 Correct 27 ms 2768 KB Output is correct
48 Correct 25 ms 2852 KB Output is correct
49 Correct 61 ms 5372 KB Output is correct
50 Correct 27 ms 5448 KB Output is correct
51 Correct 21 ms 4436 KB Output is correct
52 Correct 25 ms 5536 KB Output is correct
53 Correct 24 ms 5568 KB Output is correct
54 Correct 26 ms 6268 KB Output is correct
55 Correct 43 ms 5316 KB Output is correct