Submission #863391

# Submission time Handle Problem Language Result Execution time Memory
863391 2023-10-20T06:54:11 Z Arthas Global Warming (CEOI18_glo) C++17
100 / 100
53 ms 3932 KB
#include <bits/stdc++.h>
using namespace std;

#define all(x) x.begin(),x.end()

const int N = 3e5 + 10, INF = 2e9 + 10;

int n, x, a[N], l[N], ans;
vector <int> v(N, INF);

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> x;
  for (int i = 0; i < n; ++ i){
    cin >> a[i];
  }
  v[0] = -INF;
  for (int i = 0; i < n; ++ i){
    int p = lower_bound (all(v), a[i]) - v.begin();
    v[p] = a[i];
    l[i] = p;
    ans = max (ans, p);
  }
  for (int i = 0; i < n; ++ i){
    v[i] = INF;
  }
  v[0] = -INF;
  for (int i = n - 1; i >= 0; -- i){
    int p = lower_bound (all(v), -a[i] + x) - v.begin();
    ans = max (ans, l[i] + p - 1);
    p = lower_bound (all(v), -a[i]) - v.begin();
    v[p] = -a[i];
  }
  cout << ans;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3672 KB Output is correct
2 Correct 1 ms 3676 KB Output is correct
3 Correct 1 ms 3676 KB Output is correct
4 Correct 1 ms 3676 KB Output is correct
5 Correct 1 ms 3676 KB Output is correct
6 Correct 1 ms 3672 KB Output is correct
7 Correct 1 ms 3672 KB Output is correct
8 Correct 1 ms 3676 KB Output is correct
9 Correct 1 ms 3676 KB Output is correct
10 Correct 1 ms 3676 KB Output is correct
11 Correct 1 ms 3616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3672 KB Output is correct
2 Correct 1 ms 3676 KB Output is correct
3 Correct 1 ms 3676 KB Output is correct
4 Correct 1 ms 3676 KB Output is correct
5 Correct 1 ms 3676 KB Output is correct
6 Correct 1 ms 3672 KB Output is correct
7 Correct 1 ms 3672 KB Output is correct
8 Correct 1 ms 3676 KB Output is correct
9 Correct 1 ms 3676 KB Output is correct
10 Correct 1 ms 3676 KB Output is correct
11 Correct 1 ms 3616 KB Output is correct
12 Correct 1 ms 3672 KB Output is correct
13 Correct 1 ms 3676 KB Output is correct
14 Correct 1 ms 3672 KB Output is correct
15 Correct 1 ms 3676 KB Output is correct
16 Correct 1 ms 3676 KB Output is correct
17 Correct 1 ms 3676 KB Output is correct
18 Correct 1 ms 3676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3672 KB Output is correct
2 Correct 1 ms 3676 KB Output is correct
3 Correct 1 ms 3676 KB Output is correct
4 Correct 1 ms 3676 KB Output is correct
5 Correct 1 ms 3676 KB Output is correct
6 Correct 1 ms 3672 KB Output is correct
7 Correct 1 ms 3672 KB Output is correct
8 Correct 1 ms 3676 KB Output is correct
9 Correct 1 ms 3676 KB Output is correct
10 Correct 1 ms 3676 KB Output is correct
11 Correct 1 ms 3616 KB Output is correct
12 Correct 1 ms 3672 KB Output is correct
13 Correct 1 ms 3676 KB Output is correct
14 Correct 1 ms 3672 KB Output is correct
15 Correct 1 ms 3676 KB Output is correct
16 Correct 1 ms 3676 KB Output is correct
17 Correct 1 ms 3676 KB Output is correct
18 Correct 1 ms 3676 KB Output is correct
19 Correct 1 ms 3676 KB Output is correct
20 Correct 1 ms 3676 KB Output is correct
21 Correct 1 ms 3676 KB Output is correct
22 Correct 1 ms 3672 KB Output is correct
23 Correct 1 ms 3676 KB Output is correct
24 Correct 1 ms 3676 KB Output is correct
25 Correct 1 ms 3676 KB Output is correct
26 Correct 1 ms 3676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 3704 KB Output is correct
2 Correct 47 ms 3676 KB Output is correct
3 Correct 49 ms 3676 KB Output is correct
4 Correct 53 ms 3672 KB Output is correct
5 Correct 35 ms 3672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 3676 KB Output is correct
2 Correct 12 ms 3820 KB Output is correct
3 Correct 12 ms 3676 KB Output is correct
4 Correct 9 ms 3672 KB Output is correct
5 Correct 1 ms 3672 KB Output is correct
6 Correct 10 ms 3676 KB Output is correct
7 Correct 10 ms 3704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 3676 KB Output is correct
2 Correct 21 ms 3676 KB Output is correct
3 Correct 45 ms 3676 KB Output is correct
4 Correct 35 ms 3676 KB Output is correct
5 Correct 18 ms 3676 KB Output is correct
6 Correct 28 ms 3700 KB Output is correct
7 Correct 32 ms 3672 KB Output is correct
8 Correct 17 ms 3676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3672 KB Output is correct
2 Correct 1 ms 3676 KB Output is correct
3 Correct 1 ms 3676 KB Output is correct
4 Correct 1 ms 3676 KB Output is correct
5 Correct 1 ms 3676 KB Output is correct
6 Correct 1 ms 3672 KB Output is correct
7 Correct 1 ms 3672 KB Output is correct
8 Correct 1 ms 3676 KB Output is correct
9 Correct 1 ms 3676 KB Output is correct
10 Correct 1 ms 3676 KB Output is correct
11 Correct 1 ms 3616 KB Output is correct
12 Correct 1 ms 3672 KB Output is correct
13 Correct 1 ms 3676 KB Output is correct
14 Correct 1 ms 3672 KB Output is correct
15 Correct 1 ms 3676 KB Output is correct
16 Correct 1 ms 3676 KB Output is correct
17 Correct 1 ms 3676 KB Output is correct
18 Correct 1 ms 3676 KB Output is correct
19 Correct 1 ms 3676 KB Output is correct
20 Correct 1 ms 3676 KB Output is correct
21 Correct 1 ms 3676 KB Output is correct
22 Correct 1 ms 3672 KB Output is correct
23 Correct 1 ms 3676 KB Output is correct
24 Correct 1 ms 3676 KB Output is correct
25 Correct 1 ms 3676 KB Output is correct
26 Correct 1 ms 3676 KB Output is correct
27 Correct 47 ms 3704 KB Output is correct
28 Correct 47 ms 3676 KB Output is correct
29 Correct 49 ms 3676 KB Output is correct
30 Correct 53 ms 3672 KB Output is correct
31 Correct 35 ms 3672 KB Output is correct
32 Correct 12 ms 3676 KB Output is correct
33 Correct 12 ms 3820 KB Output is correct
34 Correct 12 ms 3676 KB Output is correct
35 Correct 9 ms 3672 KB Output is correct
36 Correct 1 ms 3672 KB Output is correct
37 Correct 10 ms 3676 KB Output is correct
38 Correct 10 ms 3704 KB Output is correct
39 Correct 21 ms 3676 KB Output is correct
40 Correct 21 ms 3676 KB Output is correct
41 Correct 45 ms 3676 KB Output is correct
42 Correct 35 ms 3676 KB Output is correct
43 Correct 18 ms 3676 KB Output is correct
44 Correct 28 ms 3700 KB Output is correct
45 Correct 32 ms 3672 KB Output is correct
46 Correct 17 ms 3676 KB Output is correct
47 Correct 26 ms 3676 KB Output is correct
48 Correct 24 ms 3676 KB Output is correct
49 Correct 49 ms 3932 KB Output is correct
50 Correct 34 ms 3676 KB Output is correct
51 Correct 28 ms 3748 KB Output is correct
52 Correct 36 ms 3700 KB Output is correct
53 Correct 30 ms 3708 KB Output is correct
54 Correct 33 ms 3676 KB Output is correct
55 Correct 39 ms 3700 KB Output is correct