Submission #483361

# Submission time Handle Problem Language Result Execution time Memory
483361 2021-10-28T23:32:59 Z BERNARB01 Global Warming (CEOI18_glo) C++17
100 / 100
66 ms 5080 KB
#include <bits/stdc++.h>

using namespace std;

const int N = (int) 2e5 + 9;
const int inf = (int) 2e9 + 9;

int n, x, a[N], dp[N];
pair<int, int> suf[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 1;
  fill(dp, dp + n, inf);
  for (int i = n - 1; i >= 0; i--) {
    int j = lower_bound(dp, dp + n, -a[i]) - dp;
    dp[j] = -a[i];
    ans = max(ans, j + 1);
    suf[i] = {j + 1, a[i]};
  }
  fill(dp, dp + n, inf);
  for (int i = 0; i < n; i++) {
    a[i] -= x;
    int j = lower_bound(dp, dp + n, a[i]) - dp;
    dp[j] = a[i];
    if (i + 1 < n) {
      int ns = suf[i + 1].second;
      int sl = suf[i + 1].first;
      j = lower_bound(dp, dp + n, ns) - dp;
      j -= 1;
      ans = max(ans, j + 1 + sl);
    }
  }
  cout << ans << '\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 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 332 KB Output is correct
7 Correct 0 ms 332 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 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 332 KB Output is correct
7 Correct 0 ms 332 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 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 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 332 KB Output is correct
7 Correct 0 ms 332 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 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 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 0 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 3332 KB Output is correct
2 Correct 66 ms 3324 KB Output is correct
3 Correct 54 ms 3396 KB Output is correct
4 Correct 59 ms 3340 KB Output is correct
5 Correct 40 ms 3352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 1100 KB Output is correct
2 Correct 12 ms 1100 KB Output is correct
3 Correct 17 ms 1004 KB Output is correct
4 Correct 12 ms 1100 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 13 ms 1100 KB Output is correct
7 Correct 14 ms 1040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 1792 KB Output is correct
2 Correct 25 ms 1760 KB Output is correct
3 Correct 53 ms 3396 KB Output is correct
4 Correct 45 ms 3424 KB Output is correct
5 Correct 19 ms 1868 KB Output is correct
6 Correct 33 ms 3276 KB Output is correct
7 Correct 42 ms 3284 KB Output is correct
8 Correct 21 ms 1868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 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 332 KB Output is correct
7 Correct 0 ms 332 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 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 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 0 ms 332 KB Output is correct
27 Correct 54 ms 3332 KB Output is correct
28 Correct 66 ms 3324 KB Output is correct
29 Correct 54 ms 3396 KB Output is correct
30 Correct 59 ms 3340 KB Output is correct
31 Correct 40 ms 3352 KB Output is correct
32 Correct 16 ms 1100 KB Output is correct
33 Correct 12 ms 1100 KB Output is correct
34 Correct 17 ms 1004 KB Output is correct
35 Correct 12 ms 1100 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 13 ms 1100 KB Output is correct
38 Correct 14 ms 1040 KB Output is correct
39 Correct 26 ms 1792 KB Output is correct
40 Correct 25 ms 1760 KB Output is correct
41 Correct 53 ms 3396 KB Output is correct
42 Correct 45 ms 3424 KB Output is correct
43 Correct 19 ms 1868 KB Output is correct
44 Correct 33 ms 3276 KB Output is correct
45 Correct 42 ms 3284 KB Output is correct
46 Correct 21 ms 1868 KB Output is correct
47 Correct 27 ms 2576 KB Output is correct
48 Correct 30 ms 2508 KB Output is correct
49 Correct 56 ms 5064 KB Output is correct
50 Correct 45 ms 4284 KB Output is correct
51 Correct 33 ms 3296 KB Output is correct
52 Correct 42 ms 4408 KB Output is correct
53 Correct 36 ms 4396 KB Output is correct
54 Correct 42 ms 5080 KB Output is correct
55 Correct 49 ms 5032 KB Output is correct