답안 #828420

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
828420 2023-08-17T09:27:22 Z OrazB 송신탑 (IOI22_towers) C++17
11 / 100
4000 ms 3992 KB
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ll long long int
#define pii pair <int, int>
#define pb push_back
#define ff first
#define ss second

const int N = 5e5+5;
int n, m;
int red[4*N], mxt[4*N];
vector<int> h = {0};

int mxbin(int x, vector<int> vec){
int l = 0, r = m-1, pos = m;
while(l <= r){
int md = (l+r)>>1;
if (vec[md] < x) l = md + 1;
else{
pos = md;
r = md - 1;
}
}
return pos+1;
}

int mnbin(int x, vector<int> vec){
int l = 0, r = m-1, pos = -1;
while(l <= r){
int md = (l+r)>>1;
if (vec[md] <= x){
pos = md;
l = md + 1;
}else r = md - 1;
}
return pos+1;
}

int tap(int pos, int l = 1, int r = m, int idx = 1){
if (l > pos) return 0;
if (r <= pos) return red[idx];
int md = (l+r)>>1;
return max(tap(pos, l, md, idx<<1), tap(pos, md+1, r, idx<<1|1));
}

void upd(int pos, int x, int l = 1, int r = m, int idx = 1){
if (l == r){
red[idx] = max(red[idx], x);
return;
}
int md = (l+r)>>1;
if (pos <= md) upd(pos, x, l, md, idx<<1);
else upd(pos, x, md+1, r, idx<<1|1);
red[idx] = max(red[idx<<1], red[idx<<1|1]);
}

int mxtap(int pos, int l = 1, int r = m, int idx = 1){
if (r < pos) return 0;
if (l >= pos) return mxt[idx];
int md = (l+r)>>1;
return max(mxtap(pos, l, md, idx<<1), mxtap(pos, md+1, r, idx<<1|1));
}

void updmx(int pos, int x, int l = 1, int r = m, int idx = 1){
if (l == r){
mxt[idx] = max(mxt[idx], x);
return;
}
int md = (l+r)>>1;
if (pos <= md) updmx(pos, x, l, md, idx<<1);
else updmx(pos, x, md+1, r, idx<<1|1);
mxt[idx] = max(mxt[idx<<1], mxt[idx<<1|1]);
}

void init(int _n, vector<int> _h){
n = _n;
for (auto i : _h) h.pb(i);
}

int max_towers(int l, int r, int D){
int ans = 0;
vector<int> vec;
l++; r++;
for (int i = l; i <= r; i++) vec.pb(h[i]);
sort(all(vec));
m = vec.size();
for (int i = r; i >= l; i--){
int posj = mxbin(h[i]+D, vec);
int pos = mnbin(h[i]-D, vec);
int y = mxtap(posj)+1;
int x = tap(pos);
upd(mxbin(h[i], vec), y);
updmx(mxbin(h[i], vec), x);
ans = max(ans, y);

}
return ans;
}

// int main ()
// {
// ios::sync_with_stdio(false);
// cin.tie(0);
// int n, q;
// cin >> n >> q;
// vector<int> h(n);
// for (int i = 0; i < n; i++) cin >> h[i];
// init(n, h);
// while(q--){
// int l, r, d;
// cin >> l >> r >> d;
// cout << max_towers(l, r, d) << '\n';
// }
// } 
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4033 ms 2208 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 2 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 0 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 2 ms 336 KB Output is correct
17 Correct 1 ms 284 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 3 ms 336 KB Output is correct
21 Correct 3 ms 336 KB Output is correct
22 Correct 3 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 2 ms 336 KB Output is correct
27 Correct 2 ms 336 KB Output is correct
28 Correct 2 ms 336 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 2 ms 336 KB Output is correct
31 Correct 2 ms 336 KB Output is correct
32 Correct 3 ms 336 KB Output is correct
33 Correct 2 ms 336 KB Output is correct
34 Correct 2 ms 336 KB Output is correct
35 Correct 2 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 2 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 0 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 2 ms 336 KB Output is correct
17 Correct 1 ms 284 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 3 ms 336 KB Output is correct
21 Correct 3 ms 336 KB Output is correct
22 Correct 3 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 2 ms 336 KB Output is correct
27 Correct 2 ms 336 KB Output is correct
28 Correct 2 ms 336 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 2 ms 336 KB Output is correct
31 Correct 2 ms 336 KB Output is correct
32 Correct 3 ms 336 KB Output is correct
33 Correct 2 ms 336 KB Output is correct
34 Correct 2 ms 336 KB Output is correct
35 Correct 2 ms 336 KB Output is correct
36 Correct 131 ms 1532 KB Output is correct
37 Correct 469 ms 2516 KB Output is correct
38 Correct 90 ms 1604 KB Output is correct
39 Correct 354 ms 1860 KB Output is correct
40 Correct 73 ms 1724 KB Output is correct
41 Correct 3008 ms 3992 KB Output is correct
42 Correct 12 ms 1728 KB Output is correct
43 Correct 991 ms 2572 KB Output is correct
44 Correct 75 ms 1740 KB Output is correct
45 Correct 11 ms 1724 KB Output is correct
46 Correct 12 ms 1700 KB Output is correct
47 Correct 477 ms 2516 KB Output is correct
48 Correct 175 ms 1816 KB Output is correct
49 Correct 37 ms 1740 KB Output is correct
50 Correct 170 ms 1740 KB Output is correct
51 Correct 573 ms 2480 KB Output is correct
52 Execution timed out 4025 ms 3920 KB Time limit exceeded
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4014 ms 3828 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4011 ms 1360 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 2 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 0 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 2 ms 336 KB Output is correct
17 Correct 1 ms 284 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 3 ms 336 KB Output is correct
21 Correct 3 ms 336 KB Output is correct
22 Correct 3 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 2 ms 336 KB Output is correct
27 Correct 2 ms 336 KB Output is correct
28 Correct 2 ms 336 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 2 ms 336 KB Output is correct
31 Correct 2 ms 336 KB Output is correct
32 Correct 3 ms 336 KB Output is correct
33 Correct 2 ms 336 KB Output is correct
34 Correct 2 ms 336 KB Output is correct
35 Correct 2 ms 336 KB Output is correct
36 Correct 131 ms 1532 KB Output is correct
37 Correct 469 ms 2516 KB Output is correct
38 Correct 90 ms 1604 KB Output is correct
39 Correct 354 ms 1860 KB Output is correct
40 Correct 73 ms 1724 KB Output is correct
41 Correct 3008 ms 3992 KB Output is correct
42 Correct 12 ms 1728 KB Output is correct
43 Correct 991 ms 2572 KB Output is correct
44 Correct 75 ms 1740 KB Output is correct
45 Correct 11 ms 1724 KB Output is correct
46 Correct 12 ms 1700 KB Output is correct
47 Correct 477 ms 2516 KB Output is correct
48 Correct 175 ms 1816 KB Output is correct
49 Correct 37 ms 1740 KB Output is correct
50 Correct 170 ms 1740 KB Output is correct
51 Correct 573 ms 2480 KB Output is correct
52 Execution timed out 4025 ms 3920 KB Time limit exceeded
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4033 ms 2208 KB Time limit exceeded
2 Halted 0 ms 0 KB -