Submission #1091531

# Submission time Handle Problem Language Result Execution time Memory
1091531 2024-09-21T07:19:30 Z stdfloat Global Warming (CEOI18_glo) C++17
55 / 100
2000 ms 4568 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() << '\n', 0;
	}
	if (x == (int)1e9) {
		vector<int> v, v2(n);
		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];
		
			v2[i] = (int)v.size();
		}

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

			ans = max(ans, v2[i - 1] + (int)u.size());
		}
		
		return cout << ans << '\n', 0;
	}

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

		ans = max(ans, (int)u.size());

		if (v.empty() || v.back() < a[i]) v.push_back(a[i]);
		else v[lower_bound(all(v), 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 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 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 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 1 ms 344 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 1 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 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 1 ms 344 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 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 5 ms 348 KB Output is correct
20 Correct 4 ms 348 KB Output is correct
21 Correct 4 ms 476 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 3 ms 348 KB Output is correct
24 Correct 3 ms 348 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 3 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 3164 KB Output is correct
2 Correct 22 ms 3164 KB Output is correct
3 Correct 22 ms 3152 KB Output is correct
4 Correct 22 ms 3160 KB Output is correct
5 Correct 12 ms 3036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2091 ms 1112 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 2136 KB Output is correct
2 Correct 21 ms 2140 KB Output is correct
3 Correct 34 ms 3928 KB Output is correct
4 Correct 16 ms 3808 KB Output is correct
5 Correct 8 ms 2136 KB Output is correct
6 Correct 14 ms 3804 KB Output is correct
7 Correct 23 ms 4568 KB Output is correct
8 Correct 14 ms 2140 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 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 1 ms 344 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 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 5 ms 348 KB Output is correct
20 Correct 4 ms 348 KB Output is correct
21 Correct 4 ms 476 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 3 ms 348 KB Output is correct
24 Correct 3 ms 348 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 3 ms 348 KB Output is correct
27 Correct 22 ms 3164 KB Output is correct
28 Correct 22 ms 3164 KB Output is correct
29 Correct 22 ms 3152 KB Output is correct
30 Correct 22 ms 3160 KB Output is correct
31 Correct 12 ms 3036 KB Output is correct
32 Execution timed out 2091 ms 1112 KB Time limit exceeded
33 Halted 0 ms 0 KB -