답안 #148092

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148092 2019-08-31T13:48:15 Z WhipppedCream Global Warming (CEOI18_glo) C++17
100 / 100
102 ms 4988 KB
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

int n, x;
const int maxn = 2e5+5;
int arr[maxn];
int L[maxn];
int lis[maxn];
int lds[maxn];

int main()
{
	scanf("%d %d", &n, &x);
	for(int i = 1; i<= n; i++) scanf("%d", arr+i);
	int cur = 0;
	for(int i = n; i>= 1; i--)
	{
		int tmp = lower_bound(L, L+cur, -arr[i])-L;
		L[tmp] = -arr[i];
		cur = max(cur, tmp+1);
		lds[i] = tmp+1;
	}
	cur = 0;
	int best = 0;
	for(int i = 1; i<= n; i++)
	{
		best = max(best, lds[i]+(int) (lower_bound(L, L+cur, arr[i]+x)-L));
		int tmp = lower_bound(L, L+cur, arr[i])-L;
		L[tmp] = arr[i];
		cur = max(cur, tmp+1);
		lis[i] = cur;
		//printf("%d: %d\n", i, best);
	}
	best = max(best, lis[n]);
	printf("%d\n", best);
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &x);
  ~~~~~^~~~~~~~~~~~~~~~~
glo.cpp:19:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 1; i<= n; i++) scanf("%d", arr+i);
                             ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 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 380 KB Output is correct
6 Correct 2 ms 380 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 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 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 380 KB Output is correct
6 Correct 2 ms 380 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 380 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 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 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 380 KB Output is correct
6 Correct 2 ms 380 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 380 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 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 78 ms 4592 KB Output is correct
2 Correct 78 ms 4600 KB Output is correct
3 Correct 78 ms 4588 KB Output is correct
4 Correct 78 ms 4600 KB Output is correct
5 Correct 45 ms 4216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 1360 KB Output is correct
2 Correct 20 ms 1400 KB Output is correct
3 Correct 20 ms 1400 KB Output is correct
4 Correct 13 ms 1400 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 12 ms 1272 KB Output is correct
7 Correct 16 ms 1400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 2424 KB Output is correct
2 Correct 38 ms 2452 KB Output is correct
3 Correct 102 ms 4592 KB Output is correct
4 Correct 47 ms 4220 KB Output is correct
5 Correct 25 ms 2268 KB Output is correct
6 Correct 42 ms 4088 KB Output is correct
7 Correct 42 ms 4728 KB Output is correct
8 Correct 30 ms 2424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 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 380 KB Output is correct
6 Correct 2 ms 380 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 380 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 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 78 ms 4592 KB Output is correct
28 Correct 78 ms 4600 KB Output is correct
29 Correct 78 ms 4588 KB Output is correct
30 Correct 78 ms 4600 KB Output is correct
31 Correct 45 ms 4216 KB Output is correct
32 Correct 20 ms 1360 KB Output is correct
33 Correct 20 ms 1400 KB Output is correct
34 Correct 20 ms 1400 KB Output is correct
35 Correct 13 ms 1400 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 12 ms 1272 KB Output is correct
38 Correct 16 ms 1400 KB Output is correct
39 Correct 35 ms 2424 KB Output is correct
40 Correct 38 ms 2452 KB Output is correct
41 Correct 102 ms 4592 KB Output is correct
42 Correct 47 ms 4220 KB Output is correct
43 Correct 25 ms 2268 KB Output is correct
44 Correct 42 ms 4088 KB Output is correct
45 Correct 42 ms 4728 KB Output is correct
46 Correct 30 ms 2424 KB Output is correct
47 Correct 39 ms 2492 KB Output is correct
48 Correct 39 ms 2416 KB Output is correct
49 Correct 78 ms 4600 KB Output is correct
50 Correct 45 ms 4216 KB Output is correct
51 Correct 38 ms 3320 KB Output is correct
52 Correct 47 ms 4320 KB Output is correct
53 Correct 42 ms 4380 KB Output is correct
54 Correct 44 ms 4988 KB Output is correct
55 Correct 63 ms 4620 KB Output is correct