Submission #1091529

# Submission time Handle Problem Language Result Execution time Memory
1091529 2024-09-21T06:44:21 Z stdfloat Global Warming (CEOI18_glo) C++17
38 / 100
2000 ms 3164 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

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

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;

	if (!x) {
		vector<int> v;
		for (int i = 0; i < n; i++) {
			if (v.empty() || v.back() < a[i]) v.push_back(a[i]);
			else v[lower_bound(all(v), a[i]) - v.begin()] = a[i];
		}

		return cout << (int)v.size(), 0;
	}

	int ans = 0;
	vector<int> v1, v2;
	for (int i = 0; i < n; i++) {
		vector<int> u1 = v1, u2 = v2;
		for (int j = i; j < n; j++) {
			a[j] += x;
			if (u1.empty() || u1.back() < a[j]) u1.push_back(a[j]);
			else u1[lower_bound(all(u1), a[j]) - u1.begin()] = a[j];

			a[j] -= x;
			if (u2.empty() || u2.back() < a[j]) u2.push_back(a[j]);
			else u2[lower_bound(all(u2), a[j]) - u2.begin()] = a[j];
		}

		ans = max({ans, (int)u1.size(), (int)u2.size()});

		if (v1.empty() || v1.back() < a[i]) v1.push_back(a[i]);
		else v1[lower_bound(all(v1), a[i]) - v1.begin()] = a[i];

		a[i] -= x;
		if (v2.empty() || v2.back() < a[i]) v2.push_back(a[i]);
		else v2[lower_bound(all(v2), a[i]) - v2.begin()] = a[i];
	}

	cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 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 0 ms 348 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 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 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 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 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 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 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 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 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 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 9 ms 348 KB Output is correct
20 Correct 8 ms 348 KB Output is correct
21 Correct 8 ms 492 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 6 ms 348 KB Output is correct
24 Correct 6 ms 348 KB Output is correct
25 Correct 3 ms 348 KB Output is correct
26 Correct 5 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 3164 KB Output is correct
2 Correct 23 ms 3160 KB Output is correct
3 Correct 23 ms 3160 KB Output is correct
4 Correct 25 ms 3164 KB Output is correct
5 Correct 12 ms 3036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2023 ms 1184 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2063 ms 2076 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 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 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 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 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 9 ms 348 KB Output is correct
20 Correct 8 ms 348 KB Output is correct
21 Correct 8 ms 492 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 6 ms 348 KB Output is correct
24 Correct 6 ms 348 KB Output is correct
25 Correct 3 ms 348 KB Output is correct
26 Correct 5 ms 344 KB Output is correct
27 Correct 23 ms 3164 KB Output is correct
28 Correct 23 ms 3160 KB Output is correct
29 Correct 23 ms 3160 KB Output is correct
30 Correct 25 ms 3164 KB Output is correct
31 Correct 12 ms 3036 KB Output is correct
32 Execution timed out 2023 ms 1184 KB Time limit exceeded
33 Halted 0 ms 0 KB -