Submission #1091572

# Submission time Handle Problem Language Result Execution time Memory
1091572 2024-09-21T09:56:01 Z stdfloat Global Warming (CEOI18_glo) C++17
100 / 100
49 ms 4412 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);

	int n, x;
	cin >> n >> x;

	vector<int> a(n);
	for (auto &i : a)
		cin >> i;

	deque<int> v;
	vector<int> u(n);
	for (int i = n - 1; i >= 0; i--) {
		if (v.empty() || v[0] > a[i]) {
			v.push_front(a[i]);
			u[i] = (int)v.size();
		}
		else {
			int t = upper_bound(v.begin(), v.end(), a[i]) - v.begin() - 1;
			u[i] = (int)v.size() - t; v[t] = a[i];
		}
	}

	v.clear();
	int ans = u[0];
	for (int i = 0; i < n; i++) {
		if (v.empty() || v.back() < a[i]) {
			ans = max(ans, (int)v.size() + u[i]);
			v.push_back(a[i]);
		}
		else {
			ans = max(ans, (int)(lower_bound(v.begin(), v.end(), a[i] + x) - v.begin()) + u[i]);
			v[lower_bound(v.begin(), v.end(), a[i]) - v.begin()] = a[i];
		}
	}

	cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 456 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 456 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 456 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 456 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 456 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 456 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 3932 KB Output is correct
2 Correct 45 ms 3924 KB Output is correct
3 Correct 45 ms 3928 KB Output is correct
4 Correct 49 ms 3932 KB Output is correct
5 Correct 21 ms 3592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1112 KB Output is correct
2 Correct 11 ms 1116 KB Output is correct
3 Correct 10 ms 1116 KB Output is correct
4 Correct 5 ms 1156 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 6 ms 1116 KB Output is correct
7 Correct 9 ms 1284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 2140 KB Output is correct
2 Correct 21 ms 2136 KB Output is correct
3 Correct 43 ms 3928 KB Output is correct
4 Correct 25 ms 3420 KB Output is correct
5 Correct 12 ms 1880 KB Output is correct
6 Correct 20 ms 3376 KB Output is correct
7 Correct 22 ms 4180 KB Output is correct
8 Correct 17 ms 2136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 456 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 456 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 46 ms 3932 KB Output is correct
28 Correct 45 ms 3924 KB Output is correct
29 Correct 45 ms 3928 KB Output is correct
30 Correct 49 ms 3932 KB Output is correct
31 Correct 21 ms 3592 KB Output is correct
32 Correct 11 ms 1112 KB Output is correct
33 Correct 11 ms 1116 KB Output is correct
34 Correct 10 ms 1116 KB Output is correct
35 Correct 5 ms 1156 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 6 ms 1116 KB Output is correct
38 Correct 9 ms 1284 KB Output is correct
39 Correct 20 ms 2140 KB Output is correct
40 Correct 21 ms 2136 KB Output is correct
41 Correct 43 ms 3928 KB Output is correct
42 Correct 25 ms 3420 KB Output is correct
43 Correct 12 ms 1880 KB Output is correct
44 Correct 20 ms 3376 KB Output is correct
45 Correct 22 ms 4180 KB Output is correct
46 Correct 17 ms 2136 KB Output is correct
47 Correct 22 ms 2140 KB Output is correct
48 Correct 25 ms 2268 KB Output is correct
49 Correct 46 ms 3916 KB Output is correct
50 Correct 21 ms 3420 KB Output is correct
51 Correct 17 ms 2904 KB Output is correct
52 Correct 25 ms 3540 KB Output is correct
53 Correct 20 ms 3676 KB Output is correct
54 Correct 21 ms 4412 KB Output is correct
55 Correct 36 ms 3928 KB Output is correct