답안 #883590

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
883590 2023-12-05T13:02:56 Z tsumondai Global Warming (CEOI18_glo) C++14
100 / 100
41 ms 4708 KB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define foru(i, l, r) for(int i = l; i <= r; i++)
#define ford(i, r, l) for(int i = r; i >= l; i--)
#define __TIME  (1.0 * clock() / CLOCKS_PER_SEC)

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int N = 2e5 + 5;

const int oo = 1e9, mod = 1e9 + 7;

int n, m, k, x, f[2][N], ans=0, a[N];
string s;
vector<int> arr;

void process() {
	cin >> n >> x;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		f[0][i] = f[1][i] = oo;
	}
	f[0][0] = f[1][0] = -oo;
	for (int i = 2; i <= n; i++) {
		int k = lower_bound(f[0] + 1, f[0] + n + 1, a[i - 1] - x) - f[0];
		f[0][k] = a[i - 1] - x;
		f[1][k] = min(f[1][k], f[0][k]);
		ans = max(ans, k);
		k = lower_bound(f[1] + 1, f[1] + n + 1, a[i]) - f[1];
		f[1][k] = a[i];
		ans = max(ans, k);
	}
	cout << ans << '\n';
	return;
}

signed main() {
	cin.tie(0)->sync_with_stdio(false);
	//freopen(".inp", "r", stdin);
	//freopen(".out", "w", stdout);
	process();
	cerr << "Time elapsed: " << __TIME << " s.\n";
	return 0;
}

// dont stop
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2504 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 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 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2504 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 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 2396 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 2392 KB Output is correct
25 Correct 2 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 4576 KB Output is correct
2 Correct 36 ms 4708 KB Output is correct
3 Correct 36 ms 4644 KB Output is correct
4 Correct 36 ms 4692 KB Output is correct
5 Correct 25 ms 3928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 3164 KB Output is correct
2 Correct 9 ms 3164 KB Output is correct
3 Correct 9 ms 3176 KB Output is correct
4 Correct 8 ms 2984 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 7 ms 2908 KB Output is correct
7 Correct 7 ms 3164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 3420 KB Output is correct
2 Correct 19 ms 3420 KB Output is correct
3 Correct 39 ms 4700 KB Output is correct
4 Correct 28 ms 3956 KB Output is correct
5 Correct 14 ms 3160 KB Output is correct
6 Correct 22 ms 3928 KB Output is correct
7 Correct 26 ms 4444 KB Output is correct
8 Correct 16 ms 3656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2504 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 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 2396 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 2392 KB Output is correct
25 Correct 2 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 36 ms 4576 KB Output is correct
28 Correct 36 ms 4708 KB Output is correct
29 Correct 36 ms 4644 KB Output is correct
30 Correct 36 ms 4692 KB Output is correct
31 Correct 25 ms 3928 KB Output is correct
32 Correct 9 ms 3164 KB Output is correct
33 Correct 9 ms 3164 KB Output is correct
34 Correct 9 ms 3176 KB Output is correct
35 Correct 8 ms 2984 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 7 ms 2908 KB Output is correct
38 Correct 7 ms 3164 KB Output is correct
39 Correct 19 ms 3420 KB Output is correct
40 Correct 19 ms 3420 KB Output is correct
41 Correct 39 ms 4700 KB Output is correct
42 Correct 28 ms 3956 KB Output is correct
43 Correct 14 ms 3160 KB Output is correct
44 Correct 22 ms 3928 KB Output is correct
45 Correct 26 ms 4444 KB Output is correct
46 Correct 16 ms 3656 KB Output is correct
47 Correct 18 ms 3416 KB Output is correct
48 Correct 17 ms 3824 KB Output is correct
49 Correct 41 ms 4708 KB Output is correct
50 Correct 25 ms 3932 KB Output is correct
51 Correct 23 ms 3420 KB Output is correct
52 Correct 27 ms 3832 KB Output is correct
53 Correct 24 ms 4048 KB Output is correct
54 Correct 27 ms 4688 KB Output is correct
55 Correct 30 ms 4692 KB Output is correct