답안 #1063746

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1063746 2024-08-18T00:56:12 Z sssamui Global Warming (CEOI18_glo) C++17
100 / 100
39 ms 5096 KB
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

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

	int n, x;
	cin >> n >> x;
	vector<int> pfxlissz(n);
	vector<int> lis(0);

	vector<int> t(n);
	for (int i = 0; i < n; i++) cin >> t[i];
	for (int i = 0; i < n; i++)
	{
		pfxlissz[i] = lis.size();
		pfxlissz[i] = lower_bound(lis.begin(), lis.end(), t[i] + x) - lis.begin();
		if (lis.empty() || (lis.back() < t[i])) lis.push_back(t[i]);
		int l = lower_bound(lis.begin(), lis.end(), t[i]) - lis.begin();
		lis[l] = t[i];
	}

	vector<int> sfxldssz(n);
	lis.clear();
	for (int i = n - 1; i > -1; i--)
	{
		if (lis.empty() || (lis.back() + t[i] < 0)) lis.push_back(-t[i]);
		sfxldssz[i] = lower_bound(lis.begin(), lis.end(), -t[i]) - lis.begin();
		lis[sfxldssz[i]] = -t[i];
	}

	int ans = sfxldssz[0];
	for (int i = 1; i < n; i++) ans = fmax(ans, pfxlissz[i] + sfxldssz[i]);
	cout << ++ans;
}
# 결과 실행 시간 메모리 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 412 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
# 결과 실행 시간 메모리 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 412 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 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 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 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 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 412 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 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 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 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 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 3964 KB Output is correct
2 Correct 39 ms 4740 KB Output is correct
3 Correct 39 ms 4552 KB Output is correct
4 Correct 37 ms 4688 KB Output is correct
5 Correct 20 ms 4316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1372 KB Output is correct
2 Correct 10 ms 1360 KB Output is correct
3 Correct 10 ms 1344 KB Output is correct
4 Correct 5 ms 1372 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 6 ms 1372 KB Output is correct
7 Correct 7 ms 1372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 2392 KB Output is correct
2 Correct 17 ms 2396 KB Output is correct
3 Correct 34 ms 3928 KB Output is correct
4 Correct 21 ms 4060 KB Output is correct
5 Correct 10 ms 2272 KB Output is correct
6 Correct 20 ms 3892 KB Output is correct
7 Correct 22 ms 4308 KB Output is correct
8 Correct 14 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 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 412 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 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 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 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 1 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 37 ms 3964 KB Output is correct
28 Correct 39 ms 4740 KB Output is correct
29 Correct 39 ms 4552 KB Output is correct
30 Correct 37 ms 4688 KB Output is correct
31 Correct 20 ms 4316 KB Output is correct
32 Correct 10 ms 1372 KB Output is correct
33 Correct 10 ms 1360 KB Output is correct
34 Correct 10 ms 1344 KB Output is correct
35 Correct 5 ms 1372 KB Output is correct
36 Correct 0 ms 604 KB Output is correct
37 Correct 6 ms 1372 KB Output is correct
38 Correct 7 ms 1372 KB Output is correct
39 Correct 17 ms 2392 KB Output is correct
40 Correct 17 ms 2396 KB Output is correct
41 Correct 34 ms 3928 KB Output is correct
42 Correct 21 ms 4060 KB Output is correct
43 Correct 10 ms 2272 KB Output is correct
44 Correct 20 ms 3892 KB Output is correct
45 Correct 22 ms 4308 KB Output is correct
46 Correct 14 ms 2396 KB Output is correct
47 Correct 18 ms 2396 KB Output is correct
48 Correct 18 ms 2392 KB Output is correct
49 Correct 39 ms 4572 KB Output is correct
50 Correct 20 ms 4316 KB Output is correct
51 Correct 18 ms 3620 KB Output is correct
52 Correct 20 ms 4824 KB Output is correct
53 Correct 19 ms 4568 KB Output is correct
54 Correct 24 ms 5096 KB Output is correct
55 Correct 31 ms 4688 KB Output is correct