답안 #756440

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
756440 2023-06-11T17:16:35 Z Red_Inside 송신탑 (IOI22_towers) C++17
23 / 100
4000 ms 5276 KB
#include "towers.h"
#include <bits/stdc++.h>

//#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")

#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long
 
using namespace std;
const int maxn=1e5+10,LOG=17,mod=1e9+7;
int block = 650, timer = 0;
const double eps = 1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
#define bt(i) (1 << (i))
//#define int ll
const long long inf=2e18;
#define y1 yy
#define pii pair <int, int>

int n, a[maxn], t[4*maxn];

void build(int v, int tl, int tr)
{
	if(tl == tr)
	{
		t[v] = a[tl];
		return;
	}
	build(v * 2, tl, (tl + tr) / 2);
	build(v * 2 + 1, (tl + tr) / 2 + 1, tr);
	t[v] = max(t[v * 2], t[v * 2 + 1]);
}

int getmax(int v, int tl, int tr, int l, int r)
{
	if(l <= tl && tr <= r) return t[v];
	if(l > tr || r < tl) return 0;
	return max(getmax(v * 2, tl, (tl + tr) / 2, l, r), 
	getmax(v * 2 + 1, (tl + tr) / 2 + 1, tr, l, r));
}

void init(int N, std::vector<int> H) {
	n = N;
	forn(1, i, n)
	{
		a[i] = H[i-1];
	}
	build(1, 1, n);
}

int max_towers(int l, int r, int d) {
	l++;
	r++;
	vector <pii> vec;
	forn(l, i, r)
	{
		vec.pb({a[i], i});
	}
	sort(all(vec));
	set <int> st;
	st.insert(n + 1);
	st.insert(0);
	for(auto it : vec)
	{
		int pos = it.s;
		auto iter = st.lower_bound(pos);
		int r = *iter;
		iter--;
		int l = *iter;
		if((l == 0 || getmax(1, 1, n, l + 1, pos-1) >= a[pos]+d) && 
		(r == n+1 || getmax(1, 1, n, pos+1, r-1) >= a[pos]+d))
		{
			st.insert(pos);
		}
	}
	return (int)st.size() - 2;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4072 ms 2468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 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 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 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 2 ms 292 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 2 ms 336 KB Output is correct
21 Correct 2 ms 336 KB Output is correct
22 Correct 2 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 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 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 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 2 ms 292 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 2 ms 336 KB Output is correct
21 Correct 2 ms 336 KB Output is correct
22 Correct 2 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 20 ms 1716 KB Output is correct
37 Correct 30 ms 2872 KB Output is correct
38 Correct 21 ms 2376 KB Output is correct
39 Correct 33 ms 2600 KB Output is correct
40 Correct 21 ms 2512 KB Output is correct
41 Correct 67 ms 3748 KB Output is correct
42 Correct 13 ms 2364 KB Output is correct
43 Correct 33 ms 3000 KB Output is correct
44 Correct 17 ms 2380 KB Output is correct
45 Correct 18 ms 2488 KB Output is correct
46 Correct 21 ms 2476 KB Output is correct
47 Correct 36 ms 2860 KB Output is correct
48 Correct 26 ms 2776 KB Output is correct
49 Correct 17 ms 2472 KB Output is correct
50 Correct 18 ms 2512 KB Output is correct
51 Correct 24 ms 2852 KB Output is correct
52 Correct 74 ms 4368 KB Output is correct
53 Correct 82 ms 5192 KB Output is correct
54 Correct 83 ms 5132 KB Output is correct
55 Correct 40 ms 3628 KB Output is correct
56 Correct 46 ms 3644 KB Output is correct
57 Correct 61 ms 3512 KB Output is correct
58 Correct 77 ms 3764 KB Output is correct
59 Correct 78 ms 4040 KB Output is correct
60 Correct 79 ms 5276 KB Output is correct
61 Correct 90 ms 4808 KB Output is correct
62 Correct 72 ms 4228 KB Output is correct
63 Correct 77 ms 4812 KB Output is correct
64 Correct 45 ms 3652 KB Output is correct
65 Correct 40 ms 3620 KB Output is correct
66 Correct 36 ms 3656 KB Output is correct
67 Correct 36 ms 3624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4046 ms 5072 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4011 ms 1688 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 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 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 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 2 ms 292 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 2 ms 336 KB Output is correct
21 Correct 2 ms 336 KB Output is correct
22 Correct 2 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 20 ms 1716 KB Output is correct
37 Correct 30 ms 2872 KB Output is correct
38 Correct 21 ms 2376 KB Output is correct
39 Correct 33 ms 2600 KB Output is correct
40 Correct 21 ms 2512 KB Output is correct
41 Correct 67 ms 3748 KB Output is correct
42 Correct 13 ms 2364 KB Output is correct
43 Correct 33 ms 3000 KB Output is correct
44 Correct 17 ms 2380 KB Output is correct
45 Correct 18 ms 2488 KB Output is correct
46 Correct 21 ms 2476 KB Output is correct
47 Correct 36 ms 2860 KB Output is correct
48 Correct 26 ms 2776 KB Output is correct
49 Correct 17 ms 2472 KB Output is correct
50 Correct 18 ms 2512 KB Output is correct
51 Correct 24 ms 2852 KB Output is correct
52 Correct 74 ms 4368 KB Output is correct
53 Correct 82 ms 5192 KB Output is correct
54 Correct 83 ms 5132 KB Output is correct
55 Correct 40 ms 3628 KB Output is correct
56 Correct 46 ms 3644 KB Output is correct
57 Correct 61 ms 3512 KB Output is correct
58 Correct 77 ms 3764 KB Output is correct
59 Correct 78 ms 4040 KB Output is correct
60 Correct 79 ms 5276 KB Output is correct
61 Correct 90 ms 4808 KB Output is correct
62 Correct 72 ms 4228 KB Output is correct
63 Correct 77 ms 4812 KB Output is correct
64 Correct 45 ms 3652 KB Output is correct
65 Correct 40 ms 3620 KB Output is correct
66 Correct 36 ms 3656 KB Output is correct
67 Correct 36 ms 3624 KB Output is correct
68 Execution timed out 4046 ms 5072 KB Time limit exceeded
69 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4072 ms 2468 KB Time limit exceeded
2 Halted 0 ms 0 KB -