답안 #156648

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
156648 2019-10-06T18:43:36 Z dolphingarlic Global Warming (CEOI18_glo) C++14
100 / 100
67 ms 5108 KB
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

int dp[200001], a[200001];
vector<int> lis, lds;
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    FOR(i, 0, n) {
        cin >> a[i];
        dp[i] = (lis.size() ? lower_bound(lis.begin(), lis.end(), a[i] + m) - lis.begin() : 0);

        int dist = (lis.size() ? lower_bound(lis.begin(), lis.end(), a[i]) - lis.begin() : 0);
        if (dist == lis.size()) lis.push_back(a[i]);
        else lis[dist] = a[i];
    }

    int ans = 0;
    for (int i = n - 1; ~i; i--) {
        int dist = (lds.size() ? lower_bound(lds.begin(), lds.end(), -a[i]) - lds.begin() : 0);
        if (dist == lds.size()) lds.push_back(-a[i]);
        else lds[dist] = -a[i];

        ans = max(ans, dp[i] + dist + 1);
    }

    cout << ans;
    return 0;
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:19:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (dist == lis.size()) lis.push_back(a[i]);
             ~~~~~^~~~~~~~~~~~~
glo.cpp:26:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (dist == lds.size()) lds.push_back(-a[i]);
             ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 1 ms 376 KB Output is correct
8 Correct 2 ms 416 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 1 ms 376 KB Output is correct
8 Correct 2 ms 416 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 1 ms 376 KB Output is correct
8 Correct 2 ms 416 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 504 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 67 ms 2724 KB Output is correct
2 Correct 67 ms 2704 KB Output is correct
3 Correct 67 ms 2616 KB Output is correct
4 Correct 67 ms 2808 KB Output is correct
5 Correct 42 ms 3828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 1272 KB Output is correct
2 Correct 17 ms 1144 KB Output is correct
3 Correct 17 ms 1252 KB Output is correct
4 Correct 12 ms 1400 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 12 ms 1300 KB Output is correct
7 Correct 14 ms 1272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 1912 KB Output is correct
2 Correct 30 ms 1912 KB Output is correct
3 Correct 62 ms 2652 KB Output is correct
4 Correct 45 ms 3768 KB Output is correct
5 Correct 23 ms 2308 KB Output is correct
6 Correct 40 ms 3728 KB Output is correct
7 Correct 42 ms 3700 KB Output is correct
8 Correct 27 ms 1912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 1 ms 376 KB Output is correct
8 Correct 2 ms 416 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 504 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 380 KB Output is correct
27 Correct 67 ms 2724 KB Output is correct
28 Correct 67 ms 2704 KB Output is correct
29 Correct 67 ms 2616 KB Output is correct
30 Correct 67 ms 2808 KB Output is correct
31 Correct 42 ms 3828 KB Output is correct
32 Correct 17 ms 1272 KB Output is correct
33 Correct 17 ms 1144 KB Output is correct
34 Correct 17 ms 1252 KB Output is correct
35 Correct 12 ms 1400 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 12 ms 1300 KB Output is correct
38 Correct 14 ms 1272 KB Output is correct
39 Correct 30 ms 1912 KB Output is correct
40 Correct 30 ms 1912 KB Output is correct
41 Correct 62 ms 2652 KB Output is correct
42 Correct 45 ms 3768 KB Output is correct
43 Correct 23 ms 2308 KB Output is correct
44 Correct 40 ms 3728 KB Output is correct
45 Correct 42 ms 3700 KB Output is correct
46 Correct 27 ms 1912 KB Output is correct
47 Correct 33 ms 2140 KB Output is correct
48 Correct 33 ms 2040 KB Output is correct
49 Correct 67 ms 3832 KB Output is correct
50 Correct 42 ms 4300 KB Output is correct
51 Correct 36 ms 3572 KB Output is correct
52 Correct 46 ms 4328 KB Output is correct
53 Correct 43 ms 4320 KB Output is correct
54 Correct 44 ms 5108 KB Output is correct
55 Correct 57 ms 3832 KB Output is correct