답안 #1056733

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1056733 2024-08-13T10:47:20 Z AmirAli_H1 송신탑 (IOI22_towers) C++17
23 / 100
4000 ms 12912 KB
// In the name of Allah

#include <bits/stdc++.h>
#include "towers.h"
using namespace std;

typedef			long long				ll;
typedef			pair<int, int>			pii;
typedef			pair<ll, ll>			pll;

#define			F						first
#define			S						second
#define			all(x)					(x).begin(),(x).end()
#define			len(x)					((ll) (x).size())
#define			Mp						make_pair
#define			pb						push_back
#define			endl					'\n'
#define			sep						' '

const int maxn = 1e5 + 7;
const int maxlg = 20;
const ll oo = 1e9 + 7;

int n;
ll Ax[maxn], A[maxn]; set<int> st;
int arr[maxn], rmq[maxn][maxlg];

bool cmp(int i, int j) {
	return (A[i] < A[j]);
}

void init(int N, vector<int> H) {
	n = N;
	for (int i = 0; i < n; i++) Ax[i] = H[i];
}

int get_max(int l, int r) {
	int j = __lg(r - l);
	return max(rmq[l][j], rmq[r - (1 << j)][j]);
}

bool check(int i, int j, int D) {
	if (j - i + 1 <= 2) return 0;
	int mx = get_max(i + 1, j);
	return (mx >= max(A[i], A[j]) + D);
}

bool ok(int i, int D) {
	auto it = st.lower_bound(i);
	if (it != st.end()) {
		if (!check(i, *it, D)) return 0;
	}
	if (it != st.begin()) {
		it--;
		if (!check(*it, i, D)) return 0;
	}
	return 1;
}

int max_towers(int L, int R, int D) {
	for (int j = L; j <= R; j++) A[j - L] = Ax[j];
	n = R - L + 1;
	
	for (int i = n - 1; i >= 0; i--) {
		rmq[i][0] = A[i];
		for (int j = 1; j < maxlg; j++) {
			if (i + (1 << j) - 1 >= n) break;
			rmq[i][j] = max(rmq[i][j - 1], rmq[i + (1 << (j - 1))][j - 1]);
		}
	}
	
	st.clear();
	iota(arr, arr + n, 0); sort(arr, arr + n, cmp);
	for (int j = 0; j < n; j++) {
		int i = arr[j];
		if (ok(i, D)) st.insert(i);
	}
	
	return len(st);
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4027 ms 10068 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2392 KB Output is correct
3 Correct 0 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 1 ms 2480 KB Output is correct
9 Correct 0 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 0 ms 2392 KB Output is correct
12 Correct 0 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 0 ms 2392 KB Output is correct
15 Correct 0 ms 2392 KB Output is correct
16 Correct 1 ms 2648 KB Output is correct
17 Correct 0 ms 2392 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 0 ms 2392 KB Output is correct
20 Correct 1 ms 2500 KB Output is correct
21 Correct 1 ms 2648 KB Output is correct
22 Correct 1 ms 2648 KB Output is correct
23 Correct 1 ms 2644 KB Output is correct
24 Correct 1 ms 2648 KB Output is correct
25 Correct 1 ms 2480 KB Output is correct
26 Correct 1 ms 2648 KB Output is correct
27 Correct 1 ms 2648 KB Output is correct
28 Correct 1 ms 2648 KB Output is correct
29 Correct 1 ms 2648 KB Output is correct
30 Correct 1 ms 2648 KB Output is correct
31 Correct 1 ms 2648 KB Output is correct
32 Correct 1 ms 2648 KB Output is correct
33 Correct 0 ms 2648 KB Output is correct
34 Correct 1 ms 2648 KB Output is correct
35 Correct 0 ms 2648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2392 KB Output is correct
3 Correct 0 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 1 ms 2480 KB Output is correct
9 Correct 0 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 0 ms 2392 KB Output is correct
12 Correct 0 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 0 ms 2392 KB Output is correct
15 Correct 0 ms 2392 KB Output is correct
16 Correct 1 ms 2648 KB Output is correct
17 Correct 0 ms 2392 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 0 ms 2392 KB Output is correct
20 Correct 1 ms 2500 KB Output is correct
21 Correct 1 ms 2648 KB Output is correct
22 Correct 1 ms 2648 KB Output is correct
23 Correct 1 ms 2644 KB Output is correct
24 Correct 1 ms 2648 KB Output is correct
25 Correct 1 ms 2480 KB Output is correct
26 Correct 1 ms 2648 KB Output is correct
27 Correct 1 ms 2648 KB Output is correct
28 Correct 1 ms 2648 KB Output is correct
29 Correct 1 ms 2648 KB Output is correct
30 Correct 1 ms 2648 KB Output is correct
31 Correct 1 ms 2648 KB Output is correct
32 Correct 1 ms 2648 KB Output is correct
33 Correct 0 ms 2648 KB Output is correct
34 Correct 1 ms 2648 KB Output is correct
35 Correct 0 ms 2648 KB Output is correct
36 Correct 9 ms 5720 KB Output is correct
37 Correct 13 ms 8136 KB Output is correct
38 Correct 11 ms 5840 KB Output is correct
39 Correct 12 ms 7888 KB Output is correct
40 Correct 10 ms 5940 KB Output is correct
41 Correct 29 ms 11216 KB Output is correct
42 Correct 7 ms 3920 KB Output is correct
43 Correct 11 ms 8144 KB Output is correct
44 Correct 8 ms 5736 KB Output is correct
45 Correct 7 ms 5840 KB Output is correct
46 Correct 13 ms 3928 KB Output is correct
47 Correct 15 ms 8392 KB Output is correct
48 Correct 15 ms 6324 KB Output is correct
49 Correct 13 ms 5980 KB Output is correct
50 Correct 8 ms 5840 KB Output is correct
51 Correct 19 ms 7888 KB Output is correct
52 Correct 35 ms 11980 KB Output is correct
53 Correct 40 ms 12912 KB Output is correct
54 Correct 38 ms 12752 KB Output is correct
55 Correct 14 ms 10448 KB Output is correct
56 Correct 14 ms 10548 KB Output is correct
57 Correct 30 ms 10972 KB Output is correct
58 Correct 33 ms 11472 KB Output is correct
59 Correct 34 ms 11728 KB Output is correct
60 Correct 38 ms 12752 KB Output is correct
61 Correct 36 ms 12488 KB Output is correct
62 Correct 35 ms 11736 KB Output is correct
63 Correct 37 ms 12488 KB Output is correct
64 Correct 18 ms 10448 KB Output is correct
65 Correct 13 ms 10616 KB Output is correct
66 Correct 14 ms 10448 KB Output is correct
67 Correct 13 ms 10544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4065 ms 12008 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4006 ms 5208 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2392 KB Output is correct
3 Correct 0 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 1 ms 2480 KB Output is correct
9 Correct 0 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 0 ms 2392 KB Output is correct
12 Correct 0 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 0 ms 2392 KB Output is correct
15 Correct 0 ms 2392 KB Output is correct
16 Correct 1 ms 2648 KB Output is correct
17 Correct 0 ms 2392 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 0 ms 2392 KB Output is correct
20 Correct 1 ms 2500 KB Output is correct
21 Correct 1 ms 2648 KB Output is correct
22 Correct 1 ms 2648 KB Output is correct
23 Correct 1 ms 2644 KB Output is correct
24 Correct 1 ms 2648 KB Output is correct
25 Correct 1 ms 2480 KB Output is correct
26 Correct 1 ms 2648 KB Output is correct
27 Correct 1 ms 2648 KB Output is correct
28 Correct 1 ms 2648 KB Output is correct
29 Correct 1 ms 2648 KB Output is correct
30 Correct 1 ms 2648 KB Output is correct
31 Correct 1 ms 2648 KB Output is correct
32 Correct 1 ms 2648 KB Output is correct
33 Correct 0 ms 2648 KB Output is correct
34 Correct 1 ms 2648 KB Output is correct
35 Correct 0 ms 2648 KB Output is correct
36 Correct 9 ms 5720 KB Output is correct
37 Correct 13 ms 8136 KB Output is correct
38 Correct 11 ms 5840 KB Output is correct
39 Correct 12 ms 7888 KB Output is correct
40 Correct 10 ms 5940 KB Output is correct
41 Correct 29 ms 11216 KB Output is correct
42 Correct 7 ms 3920 KB Output is correct
43 Correct 11 ms 8144 KB Output is correct
44 Correct 8 ms 5736 KB Output is correct
45 Correct 7 ms 5840 KB Output is correct
46 Correct 13 ms 3928 KB Output is correct
47 Correct 15 ms 8392 KB Output is correct
48 Correct 15 ms 6324 KB Output is correct
49 Correct 13 ms 5980 KB Output is correct
50 Correct 8 ms 5840 KB Output is correct
51 Correct 19 ms 7888 KB Output is correct
52 Correct 35 ms 11980 KB Output is correct
53 Correct 40 ms 12912 KB Output is correct
54 Correct 38 ms 12752 KB Output is correct
55 Correct 14 ms 10448 KB Output is correct
56 Correct 14 ms 10548 KB Output is correct
57 Correct 30 ms 10972 KB Output is correct
58 Correct 33 ms 11472 KB Output is correct
59 Correct 34 ms 11728 KB Output is correct
60 Correct 38 ms 12752 KB Output is correct
61 Correct 36 ms 12488 KB Output is correct
62 Correct 35 ms 11736 KB Output is correct
63 Correct 37 ms 12488 KB Output is correct
64 Correct 18 ms 10448 KB Output is correct
65 Correct 13 ms 10616 KB Output is correct
66 Correct 14 ms 10448 KB Output is correct
67 Correct 13 ms 10544 KB Output is correct
68 Execution timed out 4065 ms 12008 KB Time limit exceeded
69 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4027 ms 10068 KB Time limit exceeded
2 Halted 0 ms 0 KB -