답안 #853038

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
853038 2023-09-23T10:54:33 Z lovrot Global Warming (CEOI18_glo) C++17
100 / 100
61 ms 4020 KB
#include <cstdio> 
#include <algorithm>

using namespace std;

const int N = 2e5 + 10;
const int oo = 2e9 + 10;

int n, x, A[N]; 

int LIS[N], L[N];

int main() {
	scanf("%d%d", &n, &x); 
	for(int i = 0; i < n; ++i) LIS[i] = oo;
	for(int i = 0; i < n; ++i) {
		scanf("%d", A + i); 
		int j = lower_bound(LIS, LIS + n, A[i]) - LIS;
		LIS[j] = A[i]; 
		L[i] = j;
	}
	for(int i = 0; i < n; ++i) LIS[i] = -oo;
	int ans = 0;
	for(int i = n - 1; i >= 0; --i) {
		ans = max(ans, (int) (lower_bound(LIS, LIS + n, A[i] - x, [](int a, int b) {
			return a > b;
		}) - LIS) + L[i] + 1);
		int j = lower_bound(LIS, LIS + n, A[i], [](int a, int b) { return a > b; }) - LIS; 
		LIS[j] = A[i];
	}
	printf("%d\n", ans);
	return 0;
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  scanf("%d%d", &n, &x);
      |  ~~~~~^~~~~~~~~~~~~~~~
glo.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   scanf("%d", A + i);
      |   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 344 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 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 344 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 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 360 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 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 344 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 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 360 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 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 440 KB Output is correct
22 Correct 0 ms 436 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 432 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 3836 KB Output is correct
2 Correct 54 ms 4020 KB Output is correct
3 Correct 53 ms 4020 KB Output is correct
4 Correct 55 ms 3904 KB Output is correct
5 Correct 43 ms 3296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 1628 KB Output is correct
2 Correct 12 ms 1404 KB Output is correct
3 Correct 13 ms 1372 KB Output is correct
4 Correct 12 ms 1116 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 10 ms 1116 KB Output is correct
7 Correct 10 ms 1512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 2140 KB Output is correct
2 Correct 23 ms 2284 KB Output is correct
3 Correct 47 ms 4020 KB Output is correct
4 Correct 39 ms 3472 KB Output is correct
5 Correct 20 ms 1880 KB Output is correct
6 Correct 40 ms 3408 KB Output is correct
7 Correct 36 ms 3924 KB Output is correct
8 Correct 20 ms 2136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 344 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 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 360 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 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 440 KB Output is correct
22 Correct 0 ms 436 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 432 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 53 ms 3836 KB Output is correct
28 Correct 54 ms 4020 KB Output is correct
29 Correct 53 ms 4020 KB Output is correct
30 Correct 55 ms 3904 KB Output is correct
31 Correct 43 ms 3296 KB Output is correct
32 Correct 13 ms 1628 KB Output is correct
33 Correct 12 ms 1404 KB Output is correct
34 Correct 13 ms 1372 KB Output is correct
35 Correct 12 ms 1116 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 10 ms 1116 KB Output is correct
38 Correct 10 ms 1512 KB Output is correct
39 Correct 23 ms 2140 KB Output is correct
40 Correct 23 ms 2284 KB Output is correct
41 Correct 47 ms 4020 KB Output is correct
42 Correct 39 ms 3472 KB Output is correct
43 Correct 20 ms 1880 KB Output is correct
44 Correct 40 ms 3408 KB Output is correct
45 Correct 36 ms 3924 KB Output is correct
46 Correct 20 ms 2136 KB Output is correct
47 Correct 25 ms 2344 KB Output is correct
48 Correct 25 ms 2340 KB Output is correct
49 Correct 61 ms 4016 KB Output is correct
50 Correct 39 ms 3368 KB Output is correct
51 Correct 30 ms 2900 KB Output is correct
52 Correct 40 ms 3392 KB Output is correct
53 Correct 38 ms 3408 KB Output is correct
54 Correct 38 ms 3932 KB Output is correct
55 Correct 49 ms 4020 KB Output is correct