답안 #824950

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
824950 2023-08-14T12:19:53 Z alex_2008 Global Warming (CEOI18_glo) C++14
100 / 100
92 ms 6164 KB
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
const int N = 2e5 + 10;
int a[N], dppref[N], dpsuff[N];
int main() {
	int n, x;
	cin >> n >> x;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int sz = 0;
	vector <int> lis(n + 1, 1e9 + 10);
	lis[0] = 0;
	for (int i = 1; i <= n; i++) {
		int ind = lower_bound(lis.begin(), lis.end(), a[i]) - lis.begin();
		if (a[i] > lis[ind - 1] && a[i] < lis[ind]) {
			lis[ind] = a[i];
			if (lis[ind + 1] == 1e9 + 10) sz = ind + 1;
		}
		dppref[i] = ind;
	}
	sz = 0;
	vector <int> lds(n + 1, -1e9);
	lds[n] = 1e9 + 10;
	for (int i = n; i >= 1; i--) {
		int ind = upper_bound(lds.begin(), lds.end(), a[i] - x) - lds.begin();
		dpsuff[i] = n + 1 - ind;
		ind = upper_bound(lds.begin(), lds.end(), a[i]) - lds.begin();
		if (a[i] < lds[ind] && a[i] > lds[ind - 1]) {
			lds[ind - 1] = a[i];
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = max(ans, dppref[i] + dpsuff[i] - 1);
	}
	cout << ans << "\n";
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:15:6: warning: variable 'sz' set but not used [-Wunused-but-set-variable]
   15 |  int sz = 0;
      |      ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 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 1 ms 304 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 304 KB Output is correct
15 Correct 0 ms 304 KB Output is correct
16 Correct 1 ms 304 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 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 1 ms 304 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 304 KB Output is correct
15 Correct 0 ms 304 KB Output is correct
16 Correct 1 ms 304 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 316 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 92 ms 6084 KB Output is correct
2 Correct 90 ms 6088 KB Output is correct
3 Correct 89 ms 6124 KB Output is correct
4 Correct 90 ms 6072 KB Output is correct
5 Correct 63 ms 5248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 1740 KB Output is correct
2 Correct 22 ms 1776 KB Output is correct
3 Correct 27 ms 1716 KB Output is correct
4 Correct 16 ms 1456 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 16 ms 1476 KB Output is correct
7 Correct 20 ms 1768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 3152 KB Output is correct
2 Correct 40 ms 3216 KB Output is correct
3 Correct 84 ms 6104 KB Output is correct
4 Correct 64 ms 5332 KB Output is correct
5 Correct 32 ms 2804 KB Output is correct
6 Correct 58 ms 5160 KB Output is correct
7 Correct 74 ms 5780 KB Output is correct
8 Correct 38 ms 3152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 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 1 ms 304 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 304 KB Output is correct
15 Correct 0 ms 304 KB Output is correct
16 Correct 1 ms 304 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 316 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 92 ms 6084 KB Output is correct
28 Correct 90 ms 6088 KB Output is correct
29 Correct 89 ms 6124 KB Output is correct
30 Correct 90 ms 6072 KB Output is correct
31 Correct 63 ms 5248 KB Output is correct
32 Correct 22 ms 1740 KB Output is correct
33 Correct 22 ms 1776 KB Output is correct
34 Correct 27 ms 1716 KB Output is correct
35 Correct 16 ms 1456 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 16 ms 1476 KB Output is correct
38 Correct 20 ms 1768 KB Output is correct
39 Correct 41 ms 3152 KB Output is correct
40 Correct 40 ms 3216 KB Output is correct
41 Correct 84 ms 6104 KB Output is correct
42 Correct 64 ms 5332 KB Output is correct
43 Correct 32 ms 2804 KB Output is correct
44 Correct 58 ms 5160 KB Output is correct
45 Correct 74 ms 5780 KB Output is correct
46 Correct 38 ms 3152 KB Output is correct
47 Correct 44 ms 3120 KB Output is correct
48 Correct 44 ms 3168 KB Output is correct
49 Correct 91 ms 6072 KB Output is correct
50 Correct 64 ms 5280 KB Output is correct
51 Correct 49 ms 4072 KB Output is correct
52 Correct 66 ms 5424 KB Output is correct
53 Correct 68 ms 5536 KB Output is correct
54 Correct 76 ms 6092 KB Output is correct
55 Correct 79 ms 6164 KB Output is correct