답안 #416211

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
416211 2021-06-02T07:37:08 Z duyanh1704 Global Warming (CEOI18_glo) C++14
100 / 100
77 ms 10076 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int inf = 1e17 + 29;
int n, x, res;
vector<int> a;

vector<int> LIS(vector<int> a, int t, int d){
    vector<int> f(n + 5, inf); f[0] = -inf;
    vector<int> dp(n, 0);
    for (int i = 0; i < n; ++i){
        int k = lower_bound(f.begin(), f.end(), t * a[i] + d) - f.begin();
        dp[i] = k;
        k = lower_bound(f.begin(), f.end(), t * a[i]) - f.begin();
        f[k] = t * a[i];
    }
    return dp;
}

signed main(){
    ios::sync_with_stdio(0); cin.tie(0);

    cin >> n >> x;
    for (int i = 1; i <= n; ++i){
        int t; cin >> t;
        a.push_back(t);
    }


    vector<int> f = LIS(a, 1, 0);
    reverse(a.begin(), a.end());
    vector<int> g = LIS(a, -1, x);
    reverse(g.begin(), g.end());


    for (int i = 0; i < n; ++i)
        res = max(res, f[i] + g[i] - 1);

    cout << res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 8088 KB Output is correct
2 Correct 74 ms 9976 KB Output is correct
3 Correct 75 ms 9996 KB Output is correct
4 Correct 76 ms 10040 KB Output is correct
5 Correct 58 ms 9396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 2268 KB Output is correct
2 Correct 18 ms 2748 KB Output is correct
3 Correct 18 ms 2752 KB Output is correct
4 Correct 14 ms 2564 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 14 ms 2492 KB Output is correct
7 Correct 15 ms 2788 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 4188 KB Output is correct
2 Correct 35 ms 5172 KB Output is correct
3 Correct 72 ms 9984 KB Output is correct
4 Correct 59 ms 9240 KB Output is correct
5 Correct 29 ms 4704 KB Output is correct
6 Correct 50 ms 8884 KB Output is correct
7 Correct 54 ms 9688 KB Output is correct
8 Correct 29 ms 5220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 77 ms 8088 KB Output is correct
28 Correct 74 ms 9976 KB Output is correct
29 Correct 75 ms 9996 KB Output is correct
30 Correct 76 ms 10040 KB Output is correct
31 Correct 58 ms 9396 KB Output is correct
32 Correct 18 ms 2268 KB Output is correct
33 Correct 18 ms 2748 KB Output is correct
34 Correct 18 ms 2752 KB Output is correct
35 Correct 14 ms 2564 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 14 ms 2492 KB Output is correct
38 Correct 15 ms 2788 KB Output is correct
39 Correct 34 ms 4188 KB Output is correct
40 Correct 35 ms 5172 KB Output is correct
41 Correct 72 ms 9984 KB Output is correct
42 Correct 59 ms 9240 KB Output is correct
43 Correct 29 ms 4704 KB Output is correct
44 Correct 50 ms 8884 KB Output is correct
45 Correct 54 ms 9688 KB Output is correct
46 Correct 29 ms 5220 KB Output is correct
47 Correct 40 ms 5192 KB Output is correct
48 Correct 37 ms 5200 KB Output is correct
49 Correct 75 ms 9956 KB Output is correct
50 Correct 58 ms 9188 KB Output is correct
51 Correct 48 ms 6984 KB Output is correct
52 Correct 59 ms 9364 KB Output is correct
53 Correct 53 ms 9376 KB Output is correct
54 Correct 60 ms 10040 KB Output is correct
55 Correct 67 ms 10076 KB Output is correct