Submission #197856

# Submission time Handle Problem Language Result Execution time Memory
197856 2020-01-23T17:19:34 Z tuna Global Warming (CEOI18_glo) C++11
100 / 100
69 ms 4856 KB
#include "bits/stdc++.h"
using ll = long long;
using namespace std;

const int N = 2e5 + 1, mod = 1e9 + 7;

int n, x, ans = 0, a[N], f[2][N];

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> n >> x;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		f[0][i] = f[1][i] = INT_MAX;
	}
	f[0][0] = f[1][0] = -INT_MAX;
	for (int i = 2; i <= n; i++) {
		int k = lower_bound(f[0] + 1, f[0] + n + 1, a[i - 1] - x) - f[0];
		f[0][k] = a[i - 1] - x;
		f[1][k] = min(f[1][k], f[0][k]);
		ans = max(ans, k);
		k = lower_bound(f[1] + 1, f[1] + n + 1, a[i]) - f[1];
		f[1][k] = a[i];
		ans = max(ans, k);
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 1 ms 376 KB Output is correct
6 Correct 0 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 1 ms 376 KB Output is correct
6 Correct 0 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 248 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 296 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 1 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 1 ms 376 KB Output is correct
6 Correct 0 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 248 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 296 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 1 ms 376 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 3 ms 396 KB Output is correct
21 Correct 18 ms 380 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 4144 KB Output is correct
2 Correct 69 ms 4180 KB Output is correct
3 Correct 62 ms 4136 KB Output is correct
4 Correct 61 ms 4216 KB Output is correct
5 Correct 43 ms 3832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 1400 KB Output is correct
2 Correct 14 ms 1272 KB Output is correct
3 Correct 16 ms 1400 KB Output is correct
4 Correct 13 ms 1144 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 6 ms 1244 KB Output is correct
7 Correct 14 ms 1404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 2324 KB Output is correct
2 Correct 25 ms 2424 KB Output is correct
3 Correct 60 ms 4072 KB Output is correct
4 Correct 46 ms 3964 KB Output is correct
5 Correct 25 ms 2168 KB Output is correct
6 Correct 42 ms 3744 KB Output is correct
7 Correct 47 ms 4472 KB Output is correct
8 Correct 29 ms 2552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 1 ms 376 KB Output is correct
6 Correct 0 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 248 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 296 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 1 ms 376 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 3 ms 396 KB Output is correct
21 Correct 18 ms 380 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 62 ms 4144 KB Output is correct
28 Correct 69 ms 4180 KB Output is correct
29 Correct 62 ms 4136 KB Output is correct
30 Correct 61 ms 4216 KB Output is correct
31 Correct 43 ms 3832 KB Output is correct
32 Correct 16 ms 1400 KB Output is correct
33 Correct 14 ms 1272 KB Output is correct
34 Correct 16 ms 1400 KB Output is correct
35 Correct 13 ms 1144 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 6 ms 1244 KB Output is correct
38 Correct 14 ms 1404 KB Output is correct
39 Correct 17 ms 2324 KB Output is correct
40 Correct 25 ms 2424 KB Output is correct
41 Correct 60 ms 4072 KB Output is correct
42 Correct 46 ms 3964 KB Output is correct
43 Correct 25 ms 2168 KB Output is correct
44 Correct 42 ms 3744 KB Output is correct
45 Correct 47 ms 4472 KB Output is correct
46 Correct 29 ms 2552 KB Output is correct
47 Correct 31 ms 2584 KB Output is correct
48 Correct 32 ms 2680 KB Output is correct
49 Correct 62 ms 4664 KB Output is correct
50 Correct 45 ms 3960 KB Output is correct
51 Correct 39 ms 3064 KB Output is correct
52 Correct 50 ms 3960 KB Output is correct
53 Correct 44 ms 3960 KB Output is correct
54 Correct 51 ms 4856 KB Output is correct
55 Correct 57 ms 4728 KB Output is correct