답안 #625450

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
625450 2022-08-10T12:04:55 Z model_code 송신탑 (IOI22_towers) C++17
11 / 100
4000 ms 2260 KB
// failed/solution-fausta-tle.cpp
#include "towers.h"

#include <vector>

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const int NN = 2e5 + 5;
int ma = 0, k, a[NN], n, kan[NN], nx[NN], d[NN], m;
int ST[4 * NN];
int BIT[3 * NN];

map<int, int> me;

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

int max_towers(int L, int R, int D) {
	L++;
	R++;
	long long ans = 0;
	for(int i = L; i <= R; i++)
	{
		kan[i] = R + 1;
		int X = i;
		if(i > L && a[i] <= a[i - 1])
			X = kan[i - 1] - 1;
		for(ll j = X + 1; j <= min(R, X + 1000); j++)
			if(a[j] <= a[i] - D)
			{
				kan[i] = j;
				break;
			}
		// for(ll j = max(X + 1, (X + 1 + n)/2 - 1000); j <= min(R, (X + 1 + n)/2 + 1000); j++)
		// 	if(a[j] <= a[i] - D)
		// 	{
		// 		kan[i] = j;
		// 		break;
		// 	}
		for(ll j = max(X + 1, X - 1000); j <= R; j++)
		{
			++ans;
			if(a[j] <= a[i] - D)
			{
				
				kan[i] = j;
				break;
			}
		}
	}
	// printf("%lld\n", ans);
	for(int i = L; i <= R; i++)
	{
		nx[i] = R + 1;
		for(int j = i + 1; j <= min((int)R, i + 2000); j++)
			if(a[j] >= a[i] + D)
				nx[i] = min(nx[i], kan[j]);
		for(int j = max(i + 1, (i+1+R)/2 - 2000); j <= min((int)R, (i+1+R)/2 + 2000); j++)
		{
			if(j > nx[i])
				break;
			if(a[j] >= a[i] + D)
				nx[i] = min(nx[i], kan[j]);
		}
		for(int j = max(i + 1, (int)R - 2000); j <= R; j++)
		{
			if(j > nx[i])
				break;
			if(a[j] >= a[i] + D)
				nx[i] = min(nx[i], kan[j]);
		}
	}
	d[R + 1] = 0;
	for(int i = R; i >= L; i--)
		d[i] = max(d[i + 1], 1 + d[nx[i]]);
	return d[L];
}


/*
7 1
10 20 60 30 50 40 70
1 5 10

7 3
10 20 60 30 50 40 70
1 5 10
2 2 100
0 6 17
*/
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4011 ms 1364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 1 ms 384 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 1 ms 384 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 2 ms 356 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 5 ms 352 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 7 ms 360 KB Output is correct
21 Correct 7 ms 336 KB Output is correct
22 Correct 8 ms 364 KB Output is correct
23 Correct 12 ms 368 KB Output is correct
24 Correct 17 ms 400 KB Output is correct
25 Correct 2 ms 336 KB Output is correct
26 Correct 12 ms 336 KB Output is correct
27 Correct 10 ms 360 KB Output is correct
28 Correct 10 ms 336 KB Output is correct
29 Correct 11 ms 336 KB Output is correct
30 Correct 6 ms 336 KB Output is correct
31 Correct 18 ms 384 KB Output is correct
32 Correct 22 ms 360 KB Output is correct
33 Correct 12 ms 368 KB Output is correct
34 Correct 13 ms 368 KB Output is correct
35 Correct 11 ms 356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 1 ms 384 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 1 ms 384 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 2 ms 356 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 5 ms 352 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 7 ms 360 KB Output is correct
21 Correct 7 ms 336 KB Output is correct
22 Correct 8 ms 364 KB Output is correct
23 Correct 12 ms 368 KB Output is correct
24 Correct 17 ms 400 KB Output is correct
25 Correct 2 ms 336 KB Output is correct
26 Correct 12 ms 336 KB Output is correct
27 Correct 10 ms 360 KB Output is correct
28 Correct 10 ms 336 KB Output is correct
29 Correct 11 ms 336 KB Output is correct
30 Correct 6 ms 336 KB Output is correct
31 Correct 18 ms 384 KB Output is correct
32 Correct 22 ms 360 KB Output is correct
33 Correct 12 ms 368 KB Output is correct
34 Correct 13 ms 368 KB Output is correct
35 Correct 11 ms 356 KB Output is correct
36 Correct 155 ms 1064 KB Output is correct
37 Correct 616 ms 1476 KB Output is correct
38 Correct 168 ms 1464 KB Output is correct
39 Correct 654 ms 1468 KB Output is correct
40 Correct 105 ms 1488 KB Output is correct
41 Correct 1918 ms 1984 KB Output is correct
42 Correct 29 ms 1488 KB Output is correct
43 Correct 1918 ms 1644 KB Output is correct
44 Correct 132 ms 1456 KB Output is correct
45 Correct 43 ms 1432 KB Output is correct
46 Correct 27 ms 1456 KB Output is correct
47 Correct 266 ms 1464 KB Output is correct
48 Correct 146 ms 1452 KB Output is correct
49 Correct 61 ms 1424 KB Output is correct
50 Correct 197 ms 1460 KB Output is correct
51 Correct 1633 ms 1508 KB Output is correct
52 Correct 743 ms 2244 KB Output is correct
53 Correct 623 ms 2196 KB Output is correct
54 Correct 603 ms 2224 KB Output is correct
55 Correct 1186 ms 2252 KB Output is correct
56 Correct 3081 ms 2184 KB Output is correct
57 Correct 2485 ms 2204 KB Output is correct
58 Correct 1729 ms 2240 KB Output is correct
59 Correct 1705 ms 2240 KB Output is correct
60 Correct 646 ms 2236 KB Output is correct
61 Correct 1371 ms 2260 KB Output is correct
62 Correct 1840 ms 2160 KB Output is correct
63 Correct 1393 ms 2236 KB Output is correct
64 Execution timed out 4019 ms 1556 KB Time limit exceeded
65 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4065 ms 2164 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4021 ms 876 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 1 ms 384 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 1 ms 384 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 2 ms 356 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 5 ms 352 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 7 ms 360 KB Output is correct
21 Correct 7 ms 336 KB Output is correct
22 Correct 8 ms 364 KB Output is correct
23 Correct 12 ms 368 KB Output is correct
24 Correct 17 ms 400 KB Output is correct
25 Correct 2 ms 336 KB Output is correct
26 Correct 12 ms 336 KB Output is correct
27 Correct 10 ms 360 KB Output is correct
28 Correct 10 ms 336 KB Output is correct
29 Correct 11 ms 336 KB Output is correct
30 Correct 6 ms 336 KB Output is correct
31 Correct 18 ms 384 KB Output is correct
32 Correct 22 ms 360 KB Output is correct
33 Correct 12 ms 368 KB Output is correct
34 Correct 13 ms 368 KB Output is correct
35 Correct 11 ms 356 KB Output is correct
36 Correct 155 ms 1064 KB Output is correct
37 Correct 616 ms 1476 KB Output is correct
38 Correct 168 ms 1464 KB Output is correct
39 Correct 654 ms 1468 KB Output is correct
40 Correct 105 ms 1488 KB Output is correct
41 Correct 1918 ms 1984 KB Output is correct
42 Correct 29 ms 1488 KB Output is correct
43 Correct 1918 ms 1644 KB Output is correct
44 Correct 132 ms 1456 KB Output is correct
45 Correct 43 ms 1432 KB Output is correct
46 Correct 27 ms 1456 KB Output is correct
47 Correct 266 ms 1464 KB Output is correct
48 Correct 146 ms 1452 KB Output is correct
49 Correct 61 ms 1424 KB Output is correct
50 Correct 197 ms 1460 KB Output is correct
51 Correct 1633 ms 1508 KB Output is correct
52 Correct 743 ms 2244 KB Output is correct
53 Correct 623 ms 2196 KB Output is correct
54 Correct 603 ms 2224 KB Output is correct
55 Correct 1186 ms 2252 KB Output is correct
56 Correct 3081 ms 2184 KB Output is correct
57 Correct 2485 ms 2204 KB Output is correct
58 Correct 1729 ms 2240 KB Output is correct
59 Correct 1705 ms 2240 KB Output is correct
60 Correct 646 ms 2236 KB Output is correct
61 Correct 1371 ms 2260 KB Output is correct
62 Correct 1840 ms 2160 KB Output is correct
63 Correct 1393 ms 2236 KB Output is correct
64 Execution timed out 4019 ms 1556 KB Time limit exceeded
65 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4011 ms 1364 KB Time limit exceeded
2 Halted 0 ms 0 KB -