답안 #927475

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
927475 2024-02-15T01:13:23 Z OAleksa Global Warming (CEOI18_glo) C++14
100 / 100
48 ms 7772 KB
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define int long long
const int N = 2e5 + 69;
const int inf = 1e9 + 69;
int n, a[N], x, dp[N];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tt = 1;
  //cin >> tt;
  while (tt--) {
	  cin >> n >> x;
	  for (int i = 1;i <= n;i++)
	  	cin >> a[i];
  	int ans = 0;
  	vector<int> dp(n, inf), bst(n + 1, inf);
  	for (int i = 1;i <= n;i++) {
  		auto u = lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin();
  		ans += (dp[u] == inf);
  		dp[u] = a[i];
  		bst[i] = u + 1;
  	}
  	fill(dp.begin(), dp.end(), inf);
	 	for (int i = n;i >= 1;i--) {
	 		auto u = lower_bound(dp.begin(), dp.end(), -(a[i] - x)) - dp.begin();
	 		ans = max(ans, bst[i] + u);
	 		u = lower_bound(dp.begin(), dp.end(), -a[i]) - dp.begin();
	 		dp[u] = -a[i];
	 	}
	 	cout << ans;
  }
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2480 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2480 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2480 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 6492 KB Output is correct
2 Correct 48 ms 6488 KB Output is correct
3 Correct 48 ms 6492 KB Output is correct
4 Correct 48 ms 6492 KB Output is correct
5 Correct 34 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 3164 KB Output is correct
2 Correct 11 ms 3292 KB Output is correct
3 Correct 11 ms 3320 KB Output is correct
4 Correct 9 ms 3164 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 9 ms 3316 KB Output is correct
7 Correct 10 ms 3164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 4184 KB Output is correct
2 Correct 20 ms 4188 KB Output is correct
3 Correct 41 ms 6488 KB Output is correct
4 Correct 34 ms 6688 KB Output is correct
5 Correct 17 ms 4188 KB Output is correct
6 Correct 28 ms 6236 KB Output is correct
7 Correct 31 ms 6236 KB Output is correct
8 Correct 17 ms 4188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2480 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 48 ms 6492 KB Output is correct
28 Correct 48 ms 6488 KB Output is correct
29 Correct 48 ms 6492 KB Output is correct
30 Correct 48 ms 6492 KB Output is correct
31 Correct 34 ms 6492 KB Output is correct
32 Correct 12 ms 3164 KB Output is correct
33 Correct 11 ms 3292 KB Output is correct
34 Correct 11 ms 3320 KB Output is correct
35 Correct 9 ms 3164 KB Output is correct
36 Correct 0 ms 2396 KB Output is correct
37 Correct 9 ms 3316 KB Output is correct
38 Correct 10 ms 3164 KB Output is correct
39 Correct 20 ms 4184 KB Output is correct
40 Correct 20 ms 4188 KB Output is correct
41 Correct 41 ms 6488 KB Output is correct
42 Correct 34 ms 6688 KB Output is correct
43 Correct 17 ms 4188 KB Output is correct
44 Correct 28 ms 6236 KB Output is correct
45 Correct 31 ms 6236 KB Output is correct
46 Correct 17 ms 4188 KB Output is correct
47 Correct 23 ms 4936 KB Output is correct
48 Correct 23 ms 4956 KB Output is correct
49 Correct 48 ms 7756 KB Output is correct
50 Correct 34 ms 7256 KB Output is correct
51 Correct 30 ms 6232 KB Output is correct
52 Correct 35 ms 7248 KB Output is correct
53 Correct 29 ms 7256 KB Output is correct
54 Correct 33 ms 7772 KB Output is correct
55 Correct 40 ms 7772 KB Output is correct