답안 #495563

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
495563 2021-12-19T11:00:08 Z aris12345678 Global Warming (CEOI18_glo) C++14
100 / 100
72 ms 5372 KB
#include <bits/stdc++.h>
using namespace std;
 
const int mxN = 200005;
int t[mxN], dp1[mxN], pref[mxN], dp2[mxN];
 
int main() {
    int n, x;
    scanf("%d %d", &n, &x);
    for(int i = 0; i < n; i++)
        scanf("%d", &t[i]);
    fill(dp1, dp1+n, INT_MAX);
    int ans = 0;
    for(int i = 0; i < n; i++) {
        int pos = lower_bound(dp1, dp1+n, t[i])-dp1;
        dp1[pos] = t[i];
        pref[i] = pos+1;
        ans = max(ans, pref[i]);
    }
    fill(dp2, dp2+n, INT_MAX);
    for(int i = n-1; i >= 0; i--) {
        int res = lower_bound(dp2, dp2+n, -t[i]+x)-dp2;
        ans = max(ans, pref[i]+res);
        int pos = lower_bound(dp2, dp2+n, -t[i])-dp2;
        dp2[pos] = -t[i];
    }
    printf("%d\n", ans);
    return 0;
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d %d", &n, &x);
      |     ~~~~~^~~~~~~~~~~~~~~~~
glo.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         scanf("%d", &t[i]);
      |         ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 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 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 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 1 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 0 ms 204 KB Output is correct
16 Correct 0 ms 300 KB Output is correct
17 Correct 1 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 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 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 1 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 0 ms 204 KB Output is correct
16 Correct 0 ms 300 KB Output is correct
17 Correct 1 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 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 304 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 0 ms 336 KB Output is correct
26 Correct 1 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 3540 KB Output is correct
2 Correct 56 ms 5332 KB Output is correct
3 Correct 72 ms 5372 KB Output is correct
4 Correct 54 ms 5336 KB Output is correct
5 Correct 43 ms 4496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 1228 KB Output is correct
2 Correct 13 ms 1556 KB Output is correct
3 Correct 13 ms 1480 KB Output is correct
4 Correct 11 ms 1352 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 10 ms 1320 KB Output is correct
7 Correct 10 ms 1556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 1932 KB Output is correct
2 Correct 28 ms 2740 KB Output is correct
3 Correct 56 ms 5256 KB Output is correct
4 Correct 40 ms 4552 KB Output is correct
5 Correct 20 ms 2320 KB Output is correct
6 Correct 37 ms 4460 KB Output is correct
7 Correct 40 ms 5020 KB Output is correct
8 Correct 22 ms 2712 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 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 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 1 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 0 ms 204 KB Output is correct
16 Correct 0 ms 300 KB Output is correct
17 Correct 1 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 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 304 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 0 ms 336 KB Output is correct
26 Correct 1 ms 304 KB Output is correct
27 Correct 51 ms 3540 KB Output is correct
28 Correct 56 ms 5332 KB Output is correct
29 Correct 72 ms 5372 KB Output is correct
30 Correct 54 ms 5336 KB Output is correct
31 Correct 43 ms 4496 KB Output is correct
32 Correct 12 ms 1228 KB Output is correct
33 Correct 13 ms 1556 KB Output is correct
34 Correct 13 ms 1480 KB Output is correct
35 Correct 11 ms 1352 KB Output is correct
36 Correct 0 ms 208 KB Output is correct
37 Correct 10 ms 1320 KB Output is correct
38 Correct 10 ms 1556 KB Output is correct
39 Correct 27 ms 1932 KB Output is correct
40 Correct 28 ms 2740 KB Output is correct
41 Correct 56 ms 5256 KB Output is correct
42 Correct 40 ms 4552 KB Output is correct
43 Correct 20 ms 2320 KB Output is correct
44 Correct 37 ms 4460 KB Output is correct
45 Correct 40 ms 5020 KB Output is correct
46 Correct 22 ms 2712 KB Output is correct
47 Correct 26 ms 2824 KB Output is correct
48 Correct 32 ms 2760 KB Output is correct
49 Correct 61 ms 5300 KB Output is correct
50 Correct 40 ms 4516 KB Output is correct
51 Correct 31 ms 3428 KB Output is correct
52 Correct 40 ms 4648 KB Output is correct
53 Correct 50 ms 4660 KB Output is correct
54 Correct 46 ms 5332 KB Output is correct
55 Correct 46 ms 5276 KB Output is correct