답안 #1084121

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1084121 2024-09-05T08:45:56 Z ZeroCool Global Warming (CEOI18_glo) C++14
100 / 100
88 ms 6996 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ar array

const int LOG = 20;
const int MOD = 1e9 + 7;
const int INF = 1e18;

const int N = 2e5 + 20;


int A[N];
int pref[N];
    
signed main() {
    int n,x;
    cin>>n>>x;
    for (int i = 0; i < n; i++)cin >> A[i]; 
    int dp[n];
    for(int i = 0;i < n;i++)dp[i] = INF;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int j = lower_bound(dp, dp + n, A[i]) - dp;
        dp[j] = A[i];
        pref[i] = j + 1;
        ans = max(ans, pref[i]);
    }
    
    for(int i = 0;i < n;i++)dp[i] = INF;
    for (int i = n - 1; i >= 0; i--) {
        int j = lower_bound(dp, dp + n, -A[i] + x) - dp;
        ans = max(ans, pref[i] + j);
    
        int k =lower_bound(dp, dp + n, -A[i]) - dp;
        dp[k] = -A[i];
    }
    cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 376 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 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 376 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 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 448 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 376 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 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 448 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 448 KB Output is correct
26 Correct 1 ms 452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 6932 KB Output is correct
2 Correct 84 ms 6832 KB Output is correct
3 Correct 77 ms 6996 KB Output is correct
4 Correct 75 ms 6948 KB Output is correct
5 Correct 52 ms 6212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 1884 KB Output is correct
2 Correct 18 ms 1884 KB Output is correct
3 Correct 18 ms 1884 KB Output is correct
4 Correct 13 ms 1884 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 12 ms 1856 KB Output is correct
7 Correct 29 ms 1888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 3672 KB Output is correct
2 Correct 37 ms 3664 KB Output is correct
3 Correct 75 ms 6904 KB Output is correct
4 Correct 50 ms 6228 KB Output is correct
5 Correct 25 ms 3152 KB Output is correct
6 Correct 49 ms 5828 KB Output is correct
7 Correct 66 ms 6740 KB Output is correct
8 Correct 35 ms 3660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 376 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 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 448 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 448 KB Output is correct
26 Correct 1 ms 452 KB Output is correct
27 Correct 88 ms 6932 KB Output is correct
28 Correct 84 ms 6832 KB Output is correct
29 Correct 77 ms 6996 KB Output is correct
30 Correct 75 ms 6948 KB Output is correct
31 Correct 52 ms 6212 KB Output is correct
32 Correct 19 ms 1884 KB Output is correct
33 Correct 18 ms 1884 KB Output is correct
34 Correct 18 ms 1884 KB Output is correct
35 Correct 13 ms 1884 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 12 ms 1856 KB Output is correct
38 Correct 29 ms 1888 KB Output is correct
39 Correct 44 ms 3672 KB Output is correct
40 Correct 37 ms 3664 KB Output is correct
41 Correct 75 ms 6904 KB Output is correct
42 Correct 50 ms 6228 KB Output is correct
43 Correct 25 ms 3152 KB Output is correct
44 Correct 49 ms 5828 KB Output is correct
45 Correct 66 ms 6740 KB Output is correct
46 Correct 35 ms 3660 KB Output is correct
47 Correct 36 ms 3668 KB Output is correct
48 Correct 38 ms 3660 KB Output is correct
49 Correct 77 ms 6992 KB Output is correct
50 Correct 50 ms 6092 KB Output is correct
51 Correct 51 ms 4784 KB Output is correct
52 Correct 54 ms 6236 KB Output is correct
53 Correct 50 ms 6228 KB Output is correct
54 Correct 64 ms 6996 KB Output is correct
55 Correct 67 ms 6996 KB Output is correct