# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
259883 | 2020-08-08T18:47:13 Z | peuch | Global Warming (CEOI18_glo) | C++17 | 83 ms | 4676 KB |
#include<bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 10; const int INF = 2e9 + 7; int n, x; int v[MAXN]; int dp[MAXN]; int maxi[MAXN]; int ans; int main(){ scanf("%d %d", &n, &x); for(int i = 1; i <= n; i++) scanf("%d", &v[i]); for(int j = 1; j <= n; j++) dp[j] = INF; for(int i = 1; i <= n; i++){ int k = lower_bound(dp, dp + 1 + n, v[i]) - dp; dp[k] = v[i]; maxi[i] = k; ans = max(ans, k); } for(int j = 1; j <= n; j++) dp[j] = INF; dp[0] = -INF; for(int i = n; i > 0; i--){ int aux = lower_bound(dp, dp + 1 + n, -v[i]) - dp; aux--; int k = lower_bound(dp, dp + 1 + n, -v[i] - x) - dp; dp[k] = -v[i] - x; ans = max(ans, maxi[i] + aux); ans = max(ans, k); } printf("%d\n", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 384 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 384 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 1 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 0 ms | 384 KB | Output is correct |
16 | Correct | 0 ms | 384 KB | Output is correct |
17 | Correct | 0 ms | 384 KB | Output is correct |
18 | Correct | 0 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 384 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 1 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 0 ms | 384 KB | Output is correct |
16 | Correct | 0 ms | 384 KB | Output is correct |
17 | Correct | 0 ms | 384 KB | Output is correct |
18 | Correct | 0 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 1 ms | 384 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 80 ms | 2680 KB | Output is correct |
2 | Correct | 80 ms | 2680 KB | Output is correct |
3 | Correct | 81 ms | 2680 KB | Output is correct |
4 | Correct | 83 ms | 2680 KB | Output is correct |
5 | Correct | 65 ms | 2680 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 896 KB | Output is correct |
2 | Correct | 20 ms | 896 KB | Output is correct |
3 | Correct | 19 ms | 896 KB | Output is correct |
4 | Correct | 16 ms | 896 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 15 ms | 1152 KB | Output is correct |
7 | Correct | 26 ms | 1408 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 55 ms | 1656 KB | Output is correct |
2 | Correct | 36 ms | 1536 KB | Output is correct |
3 | Correct | 74 ms | 2808 KB | Output is correct |
4 | Correct | 63 ms | 2680 KB | Output is correct |
5 | Correct | 30 ms | 1536 KB | Output is correct |
6 | Correct | 51 ms | 2552 KB | Output is correct |
7 | Correct | 62 ms | 2552 KB | Output is correct |
8 | Correct | 33 ms | 1560 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 384 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 1 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 0 ms | 384 KB | Output is correct |
16 | Correct | 0 ms | 384 KB | Output is correct |
17 | Correct | 0 ms | 384 KB | Output is correct |
18 | Correct | 0 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 1 ms | 384 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 80 ms | 2680 KB | Output is correct |
28 | Correct | 80 ms | 2680 KB | Output is correct |
29 | Correct | 81 ms | 2680 KB | Output is correct |
30 | Correct | 83 ms | 2680 KB | Output is correct |
31 | Correct | 65 ms | 2680 KB | Output is correct |
32 | Correct | 21 ms | 896 KB | Output is correct |
33 | Correct | 20 ms | 896 KB | Output is correct |
34 | Correct | 19 ms | 896 KB | Output is correct |
35 | Correct | 16 ms | 896 KB | Output is correct |
36 | Correct | 1 ms | 384 KB | Output is correct |
37 | Correct | 15 ms | 1152 KB | Output is correct |
38 | Correct | 26 ms | 1408 KB | Output is correct |
39 | Correct | 55 ms | 1656 KB | Output is correct |
40 | Correct | 36 ms | 1536 KB | Output is correct |
41 | Correct | 74 ms | 2808 KB | Output is correct |
42 | Correct | 63 ms | 2680 KB | Output is correct |
43 | Correct | 30 ms | 1536 KB | Output is correct |
44 | Correct | 51 ms | 2552 KB | Output is correct |
45 | Correct | 62 ms | 2552 KB | Output is correct |
46 | Correct | 33 ms | 1560 KB | Output is correct |
47 | Correct | 40 ms | 2432 KB | Output is correct |
48 | Correct | 40 ms | 2424 KB | Output is correct |
49 | Correct | 82 ms | 4600 KB | Output is correct |
50 | Correct | 68 ms | 3920 KB | Output is correct |
51 | Correct | 49 ms | 2968 KB | Output is correct |
52 | Correct | 62 ms | 3960 KB | Output is correct |
53 | Correct | 56 ms | 4088 KB | Output is correct |
54 | Correct | 61 ms | 4676 KB | Output is correct |
55 | Correct | 73 ms | 4600 KB | Output is correct |