Submission #635423

# Submission time Handle Problem Language Result Execution time Memory
635423 2022-08-26T08:40:56 Z FulopMate Global Warming (CEOI18_glo) C++17
100 / 100
120 ms 4584 KB
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn = 200010;
 
int t[maxn], vege[maxn];
int dp[maxn];
 
int main()
{
	int n, x;
	cin >> n >> x;
	for (int i = 1; i <= n; i++) cin >> t[i];
	fill(dp, dp + n + 2, INT32_MAX);
	dp[0] = INT32_MIN;
	for (int i = 1; i <= n; i++) {
		int j = upper_bound(dp, dp + n + 1, t[i]) - dp;
		if (dp[j - 1] < t[i] && t[i] < dp[j]) {
			dp[j] = t[i];
			vege[i] = j;
		}
		else {
			vege[i] = j - 1;
		}
	}
	fill(dp, dp + n + 2, INT32_MIN);
	dp[0] = INT32_MAX;
	int ans = 0;
	for (int i = n; i > 0; i--) {
		int l = 0, r = n + 1;
		while (l + 1 < r) {
			int m = (l + r) / 2;
			if (dp[m] > t[i] - x)l = m;
			else r = m;
		}
		ans = max(ans, vege[i] + l);
 
		l = 0, r = n + 1;
		while (l + 1 < r) {
			int m = (l + r) / 2;
			if (dp[m] > t[i])l = m;
			else r = m;
		}
		dp[l + 1] = t[i];
	}
	cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 312 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 113 ms 2612 KB Output is correct
2 Correct 114 ms 4552 KB Output is correct
3 Correct 111 ms 4560 KB Output is correct
4 Correct 107 ms 4512 KB Output is correct
5 Correct 74 ms 3756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 904 KB Output is correct
2 Correct 27 ms 1372 KB Output is correct
3 Correct 27 ms 1288 KB Output is correct
4 Correct 19 ms 1108 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 19 ms 1100 KB Output is correct
7 Correct 28 ms 1356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 1440 KB Output is correct
2 Correct 50 ms 2380 KB Output is correct
3 Correct 102 ms 4556 KB Output is correct
4 Correct 74 ms 3676 KB Output is correct
5 Correct 37 ms 2164 KB Output is correct
6 Correct 71 ms 3596 KB Output is correct
7 Correct 94 ms 4380 KB Output is correct
8 Correct 47 ms 2420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 312 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 113 ms 2612 KB Output is correct
28 Correct 114 ms 4552 KB Output is correct
29 Correct 111 ms 4560 KB Output is correct
30 Correct 107 ms 4512 KB Output is correct
31 Correct 74 ms 3756 KB Output is correct
32 Correct 27 ms 904 KB Output is correct
33 Correct 27 ms 1372 KB Output is correct
34 Correct 27 ms 1288 KB Output is correct
35 Correct 19 ms 1108 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 19 ms 1100 KB Output is correct
38 Correct 28 ms 1356 KB Output is correct
39 Correct 51 ms 1440 KB Output is correct
40 Correct 50 ms 2380 KB Output is correct
41 Correct 102 ms 4556 KB Output is correct
42 Correct 74 ms 3676 KB Output is correct
43 Correct 37 ms 2164 KB Output is correct
44 Correct 71 ms 3596 KB Output is correct
45 Correct 94 ms 4380 KB Output is correct
46 Correct 47 ms 2420 KB Output is correct
47 Correct 55 ms 2400 KB Output is correct
48 Correct 56 ms 2400 KB Output is correct
49 Correct 120 ms 4552 KB Output is correct
50 Correct 78 ms 3688 KB Output is correct
51 Correct 56 ms 2916 KB Output is correct
52 Correct 77 ms 3884 KB Output is correct
53 Correct 75 ms 3852 KB Output is correct
54 Correct 96 ms 4584 KB Output is correct
55 Correct 99 ms 4568 KB Output is correct