답안 #774318

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
774318 2023-07-05T14:12:29 Z parsadox2 Global Warming (CEOI18_glo) C++14
100 / 100
52 ms 6964 KB
#include <bits/stdc++.h>
#define pb 		push_back
#define F		first
#define S 		second
#define debug(x)    cout << #x << "= " << x << ", "
#define ll 		long long
#define fast 		ios::sync_with_stdio(false), cin.tie(0),  cout.tie(0)
#define SZ(x)         (int) x.size()
#define wall 		cout << endl;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define int long long 
const int maxn = 2e5 + 10 , inf = 2e9 + 10;
int n , ar[maxn] , x , lis[maxn] , lds[maxn];

int32_t main()
{
	fast;
	cin >> n >> x;
	for(int i = 0 ; i < n ; i++)  cin >> ar[i];
	lis[0] = inf;
	for(int i = 1 ; i < maxn ; i++)  lis[i] = -inf;
	for(int i = n - 1 ; i > -1 ; i--)
	{
		int low = 0 , high = maxn;
		while(high - low > 1)
		{
			int mid = (high + low) >> 1;
			if(lis[mid] <= ar[i])
				high = mid;
			else 
				low = mid;
		}
		lis[high] = ar[i];
		lds[i] = high;
	}
	int ans = 0;
	for(int i = 0 ; i <= n ; i++)  if(lis[i] != -inf)  ans = i;
	lis[0] = -inf;
	for(int i = 1 ; i < maxn ; i++)  lis[i] = inf;
	for(int i = 0 ; i < n - 1 ; i++)
	{
		int low = 0 , high = maxn;
		while(high - low > 1)
		{
			int mid = (high + low) >> 1;
			if(lis[mid] < ar[i])  low = mid;
			else high = mid;
		}
		lis[high] = ar[i];
		int tmp = ar[i + 1] + x;
		low = 0;   high = maxn;
		while(high - low > 1)
		{
			int mid = (high + low) >> 1;
			if(lis[mid] < tmp)  low = mid;
			else  high = mid;
		}
		ans = max(ans , low + lds[i + 1]);
	}
	cout << ans << '\n';
	return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 1 ms 1876 KB Output is correct
8 Correct 1 ms 1876 KB Output is correct
9 Correct 1 ms 1876 KB Output is correct
10 Correct 1 ms 1876 KB Output is correct
11 Correct 2 ms 1876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 1 ms 1876 KB Output is correct
8 Correct 1 ms 1876 KB Output is correct
9 Correct 1 ms 1876 KB Output is correct
10 Correct 1 ms 1876 KB Output is correct
11 Correct 2 ms 1876 KB Output is correct
12 Correct 1 ms 1876 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 1876 KB Output is correct
15 Correct 1 ms 1876 KB Output is correct
16 Correct 1 ms 1876 KB Output is correct
17 Correct 1 ms 1876 KB Output is correct
18 Correct 1 ms 1876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 1 ms 1876 KB Output is correct
8 Correct 1 ms 1876 KB Output is correct
9 Correct 1 ms 1876 KB Output is correct
10 Correct 1 ms 1876 KB Output is correct
11 Correct 2 ms 1876 KB Output is correct
12 Correct 1 ms 1876 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 1876 KB Output is correct
15 Correct 1 ms 1876 KB Output is correct
16 Correct 1 ms 1876 KB Output is correct
17 Correct 1 ms 1876 KB Output is correct
18 Correct 1 ms 1876 KB Output is correct
19 Correct 1 ms 1876 KB Output is correct
20 Correct 2 ms 1876 KB Output is correct
21 Correct 1 ms 1876 KB Output is correct
22 Correct 1 ms 1876 KB Output is correct
23 Correct 1 ms 1876 KB Output is correct
24 Correct 2 ms 1876 KB Output is correct
25 Correct 1 ms 1876 KB Output is correct
26 Correct 1 ms 1876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 5004 KB Output is correct
2 Correct 48 ms 5024 KB Output is correct
3 Correct 48 ms 5028 KB Output is correct
4 Correct 52 ms 5004 KB Output is correct
5 Correct 45 ms 4928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 2644 KB Output is correct
2 Correct 12 ms 2688 KB Output is correct
3 Correct 15 ms 2692 KB Output is correct
4 Correct 12 ms 2604 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 11 ms 2684 KB Output is correct
7 Correct 12 ms 2668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 3372 KB Output is correct
2 Correct 31 ms 4400 KB Output is correct
3 Correct 48 ms 6932 KB Output is correct
4 Correct 44 ms 6124 KB Output is correct
5 Correct 21 ms 3924 KB Output is correct
6 Correct 38 ms 5960 KB Output is correct
7 Correct 45 ms 6664 KB Output is correct
8 Correct 24 ms 4428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 1 ms 1876 KB Output is correct
8 Correct 1 ms 1876 KB Output is correct
9 Correct 1 ms 1876 KB Output is correct
10 Correct 1 ms 1876 KB Output is correct
11 Correct 2 ms 1876 KB Output is correct
12 Correct 1 ms 1876 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 1876 KB Output is correct
15 Correct 1 ms 1876 KB Output is correct
16 Correct 1 ms 1876 KB Output is correct
17 Correct 1 ms 1876 KB Output is correct
18 Correct 1 ms 1876 KB Output is correct
19 Correct 1 ms 1876 KB Output is correct
20 Correct 2 ms 1876 KB Output is correct
21 Correct 1 ms 1876 KB Output is correct
22 Correct 1 ms 1876 KB Output is correct
23 Correct 1 ms 1876 KB Output is correct
24 Correct 2 ms 1876 KB Output is correct
25 Correct 1 ms 1876 KB Output is correct
26 Correct 1 ms 1876 KB Output is correct
27 Correct 47 ms 5004 KB Output is correct
28 Correct 48 ms 5024 KB Output is correct
29 Correct 48 ms 5028 KB Output is correct
30 Correct 52 ms 5004 KB Output is correct
31 Correct 45 ms 4928 KB Output is correct
32 Correct 12 ms 2644 KB Output is correct
33 Correct 12 ms 2688 KB Output is correct
34 Correct 15 ms 2692 KB Output is correct
35 Correct 12 ms 2604 KB Output is correct
36 Correct 1 ms 1876 KB Output is correct
37 Correct 11 ms 2684 KB Output is correct
38 Correct 12 ms 2668 KB Output is correct
39 Correct 25 ms 3372 KB Output is correct
40 Correct 31 ms 4400 KB Output is correct
41 Correct 48 ms 6932 KB Output is correct
42 Correct 44 ms 6124 KB Output is correct
43 Correct 21 ms 3924 KB Output is correct
44 Correct 38 ms 5960 KB Output is correct
45 Correct 45 ms 6664 KB Output is correct
46 Correct 24 ms 4428 KB Output is correct
47 Correct 25 ms 4412 KB Output is correct
48 Correct 25 ms 4308 KB Output is correct
49 Correct 48 ms 6856 KB Output is correct
50 Correct 43 ms 6112 KB Output is correct
51 Correct 32 ms 5092 KB Output is correct
52 Correct 46 ms 6348 KB Output is correct
53 Correct 47 ms 6220 KB Output is correct
54 Correct 44 ms 6964 KB Output is correct
55 Correct 47 ms 6884 KB Output is correct