답안 #136259

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
136259 2019-07-25T05:09:25 Z SOIVIEONE Global Warming (CEOI18_glo) C++14
100 / 100
198 ms 7884 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 222222;
ll a[N], l[N], d[N];
pair<int, int> change[N];
int main()
{
	int n, x;
	cin >> n >> x;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	int lis = 0;
	for(int i = 0; i <= n; i ++)
		l[i] = 2e9;
	int ans = 0;
	for(int i = 1; i <= n; i ++)
	{
		int id = lower_bound(l + 1, l + n + 1, a[i]) - l;
		change[i] = {id, l[id]};
		l[id] = a[i];
		ans = max(ans, id);
	}
	int lds = 0;
	for(int i = n; i >= 1; i --)
	{
		int id = lower_bound(d + 1, d + n + 1, a[i] + x, greater<int>()) - d; 
		d[id] = a[i] + x;
		l[change[i].first] = change[i].second;
		// cout << i << ' ' << id << '\n';
		// for(int j = 0; j <= lds - 1; j ++)
			// cout << d[j] << ' ';
		// cout << '\n';
		int it = lower_bound(l + 1, l + n + 1, a[i] + x) - l-1;	
		ans = max(ans, it + id);
	}	
	cout << ans;
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:16:6: warning: unused variable 'lis' [-Wunused-variable]
  int lis = 0;
      ^~~
glo.cpp:27:6: warning: unused variable 'lds' [-Wunused-variable]
  int lds = 0;
      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 3 ms 380 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 380 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 193 ms 5116 KB Output is correct
2 Correct 198 ms 5132 KB Output is correct
3 Correct 193 ms 5224 KB Output is correct
4 Correct 193 ms 5116 KB Output is correct
5 Correct 138 ms 5972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 1528 KB Output is correct
2 Correct 48 ms 1528 KB Output is correct
3 Correct 48 ms 1528 KB Output is correct
4 Correct 35 ms 1784 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 35 ms 1756 KB Output is correct
7 Correct 46 ms 1528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 92 ms 2800 KB Output is correct
2 Correct 92 ms 3704 KB Output is correct
3 Correct 186 ms 6136 KB Output is correct
4 Correct 137 ms 6776 KB Output is correct
5 Correct 72 ms 3668 KB Output is correct
6 Correct 131 ms 6648 KB Output is correct
7 Correct 169 ms 6648 KB Output is correct
8 Correct 90 ms 3716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 3 ms 380 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 380 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 193 ms 5116 KB Output is correct
28 Correct 198 ms 5132 KB Output is correct
29 Correct 193 ms 5224 KB Output is correct
30 Correct 193 ms 5116 KB Output is correct
31 Correct 138 ms 5972 KB Output is correct
32 Correct 48 ms 1528 KB Output is correct
33 Correct 48 ms 1528 KB Output is correct
34 Correct 48 ms 1528 KB Output is correct
35 Correct 35 ms 1784 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 35 ms 1756 KB Output is correct
38 Correct 46 ms 1528 KB Output is correct
39 Correct 92 ms 2800 KB Output is correct
40 Correct 92 ms 3704 KB Output is correct
41 Correct 186 ms 6136 KB Output is correct
42 Correct 137 ms 6776 KB Output is correct
43 Correct 72 ms 3668 KB Output is correct
44 Correct 131 ms 6648 KB Output is correct
45 Correct 169 ms 6648 KB Output is correct
46 Correct 90 ms 3716 KB Output is correct
47 Correct 98 ms 3836 KB Output is correct
48 Correct 96 ms 3704 KB Output is correct
49 Correct 194 ms 6980 KB Output is correct
50 Correct 137 ms 7032 KB Output is correct
51 Correct 106 ms 5556 KB Output is correct
52 Correct 145 ms 7032 KB Output is correct
53 Correct 148 ms 7032 KB Output is correct
54 Correct 192 ms 7884 KB Output is correct
55 Correct 182 ms 7004 KB Output is correct