# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
259934 | 2020-08-08T20:18:15 Z | Kenzo_1114 | Global Warming (CEOI18_glo) | C++17 | 83 ms | 5152 KB |
#include<bits/stdc++.h> using namespace std; const int MAXN = 200010; const long long int INF = 2e10 + 9; int n; long long int x, t[MAXN], dp[MAXN], ans[MAXN]; int main () { scanf("%d %lld", &n, &x); dp[0] = INF; for(int i = 1; i <= n; i++) scanf("%lld", &t[i]), dp[i] = INF; long long int ANS = 0; for(int i = 1; i <= n; i++) { int it = lower_bound(dp, dp + n, t[i]) - dp; dp[it] = t[i]; ans[i] = it + 1; ANS = max(ANS, ans[i]); } dp[0] = INF; for(int i = 1; i <= n; i++) t[i] = -t[i], dp[i] = INF; for(int i = n; i > 0; i--) { int id = lower_bound(dp, dp + n, t[i] + x) - dp; int it = lower_bound(dp, dp + n, t[i]) - dp; dp[it] = t[i]; ANS = max(ANS, id + ans[i]); } printf("%lld\n", ANS); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 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 | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 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 | 1 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 | 1 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 | 1 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 | 1 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 | 1 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 | 1 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 | 82 ms | 4984 KB | Output is correct |
2 | Correct | 81 ms | 4984 KB | Output is correct |
3 | Correct | 81 ms | 5068 KB | Output is correct |
4 | Correct | 83 ms | 4984 KB | Output is correct |
5 | Correct | 63 ms | 5152 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 1536 KB | Output is correct |
2 | Correct | 25 ms | 1536 KB | Output is correct |
3 | Correct | 19 ms | 1536 KB | Output is correct |
4 | Correct | 16 ms | 1536 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 15 ms | 1536 KB | Output is correct |
7 | Correct | 16 ms | 1536 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 36 ms | 2680 KB | Output is correct |
2 | Correct | 36 ms | 2680 KB | Output is correct |
3 | Correct | 75 ms | 4984 KB | Output is correct |
4 | Correct | 61 ms | 4948 KB | Output is correct |
5 | Correct | 31 ms | 2688 KB | Output is correct |
6 | Correct | 52 ms | 4728 KB | Output is correct |
7 | Correct | 63 ms | 4728 KB | Output is correct |
8 | Correct | 32 ms | 2688 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 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 | 1 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 | 1 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 | 82 ms | 4984 KB | Output is correct |
28 | Correct | 81 ms | 4984 KB | Output is correct |
29 | Correct | 81 ms | 5068 KB | Output is correct |
30 | Correct | 83 ms | 4984 KB | Output is correct |
31 | Correct | 63 ms | 5152 KB | Output is correct |
32 | Correct | 22 ms | 1536 KB | Output is correct |
33 | Correct | 25 ms | 1536 KB | Output is correct |
34 | Correct | 19 ms | 1536 KB | Output is correct |
35 | Correct | 16 ms | 1536 KB | Output is correct |
36 | Correct | 1 ms | 384 KB | Output is correct |
37 | Correct | 15 ms | 1536 KB | Output is correct |
38 | Correct | 16 ms | 1536 KB | Output is correct |
39 | Correct | 36 ms | 2680 KB | Output is correct |
40 | Correct | 36 ms | 2680 KB | Output is correct |
41 | Correct | 75 ms | 4984 KB | Output is correct |
42 | Correct | 61 ms | 4948 KB | Output is correct |
43 | Correct | 31 ms | 2688 KB | Output is correct |
44 | Correct | 52 ms | 4728 KB | Output is correct |
45 | Correct | 63 ms | 4728 KB | Output is correct |
46 | Correct | 32 ms | 2688 KB | Output is correct |
47 | Correct | 40 ms | 2808 KB | Output is correct |
48 | Correct | 40 ms | 2680 KB | Output is correct |
49 | Correct | 83 ms | 5060 KB | Output is correct |
50 | Correct | 61 ms | 4984 KB | Output is correct |
51 | Correct | 50 ms | 3832 KB | Output is correct |
52 | Correct | 63 ms | 4984 KB | Output is correct |
53 | Correct | 54 ms | 4984 KB | Output is correct |
54 | Correct | 59 ms | 4984 KB | Output is correct |
55 | Correct | 67 ms | 4984 KB | Output is correct |