답안 #836948

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
836948 2023-08-24T17:53:02 Z Abrar_Al_Samit 송신탑 (IOI22_towers) C++17
23 / 100
4000 ms 7700 KB
#include "towers.h"
#include <bits/stdc++.h>
 
using namespace std;
 
//subtask 2 & 3
 
const int nax = 100005;
int n;
bool l_maxima[nax];
int l[nax], r[nax];
int h[nax];
int pmax[nax], nmax[nax];
 
void init(int N, vector<int> H) {
  n = N;
 
  for(int i=0; i<n; ++i) h[i] = H[i]; 
}
 
bool is[nax];
int max_towers(int L, int R, int D) {
	vector<int>H;
	for(int i=L; i<=R; ++i) {
		H.push_back(h[i]);
	}
	n = R-L+1;
 
	int mn = H[0];
  	for(int i=1; i<n-1; ++i) {
    	if(H[i]>H[i-1] && H[i]>H[i+1]) {
    		l_maxima[i] = 1;
    		l[i] = H[i] - mn;
    		mn = 2e9;
    	} else {
    		mn = min(mn, H[i]);
    	}
  	}
 
 
  	int p = -1;
  	for(int i=1; i<n; ++i) if(l_maxima[i]) {
  		pmax[i] = p;
  		p = i;
  	}
  	p = n;
  	for(int i=n-1; i>0; --i) if(l_maxima[i]) {
  		nmax[i] = p;
  		p = i;
  	}
 
  	mn = H[n-1];
  	for(int i=n-2; i>0; --i) {
  		if(l_maxima[i]) {
  			r[i] = H[i] - mn;
  			mn = 2e9;
  		} else {
  			mn = min(mn, H[i]);
  		}
  	}
 
 
 
	int ret = 1;
 
	set<pair<int,int>>s;
	for(int i=1; i<n; ++i) if(l_maxima[i]) {
		s.insert(make_pair(min(l[i], r[i]), i));
		is[i] = 1;
	}
 
	while(!s.empty() && s.begin()->first<D) {
		auto [x, i] = *s.begin();
		s.erase(s.begin());
		is[i] = 0;
 
		int lmin = H[i] - l[i], rmin = H[i] - r[i];
 
		if(pmax[i]!=-1 && is[pmax[i]]) {
			s.erase(make_pair(min(l[pmax[i]], r[pmax[i]]), pmax[i]));
			r[pmax[i]] = max(r[pmax[i]], H[pmax[i]] - rmin);
			s.insert(make_pair(min(l[pmax[i]], r[pmax[i]]), pmax[i]));

			nmax[pmax[i]] = nmax[i];
		}
		if(nmax[i]!=n && is[nmax[i]]) {
			s.erase(make_pair(min(l[nmax[i]], r[nmax[i]]), nmax[i]));
			l[nmax[i]] = max(l[nmax[i]], H[nmax[i]] - lmin);
			s.insert(make_pair(min(l[nmax[i]], r[nmax[i]]), nmax[i]));

			pmax[nmax[i]] = pmax[i];
		}
	} 
	ret = max(ret, (int)s.size() + 1);
	return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4038 ms 2344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 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 304 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 0 ms 208 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 0 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 0 ms 336 KB Output is correct
33 Correct 0 ms 336 KB Output is correct
34 Correct 0 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 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 304 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 0 ms 208 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 0 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 0 ms 336 KB Output is correct
33 Correct 0 ms 336 KB Output is correct
34 Correct 0 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 8 ms 1452 KB Output is correct
37 Correct 17 ms 2336 KB Output is correct
38 Correct 11 ms 1564 KB Output is correct
39 Correct 22 ms 2460 KB Output is correct
40 Correct 10 ms 1564 KB Output is correct
41 Correct 38 ms 4756 KB Output is correct
42 Correct 9 ms 1428 KB Output is correct
43 Correct 11 ms 1440 KB Output is correct
44 Correct 15 ms 1436 KB Output is correct
45 Correct 15 ms 1352 KB Output is correct
46 Correct 9 ms 1488 KB Output is correct
47 Correct 18 ms 2332 KB Output is correct
48 Correct 17 ms 1948 KB Output is correct
49 Correct 10 ms 1560 KB Output is correct
50 Correct 9 ms 1472 KB Output is correct
51 Correct 9 ms 1456 KB Output is correct
52 Correct 18 ms 4736 KB Output is correct
53 Correct 21 ms 5576 KB Output is correct
54 Correct 22 ms 5552 KB Output is correct
55 Correct 9 ms 1980 KB Output is correct
56 Correct 16 ms 1988 KB Output is correct
57 Correct 38 ms 4652 KB Output is correct
58 Correct 32 ms 4912 KB Output is correct
59 Correct 24 ms 4672 KB Output is correct
60 Correct 22 ms 5548 KB Output is correct
61 Correct 34 ms 5520 KB Output is correct
62 Correct 37 ms 5536 KB Output is correct
63 Correct 27 ms 5528 KB Output is correct
64 Correct 15 ms 1968 KB Output is correct
65 Correct 10 ms 1936 KB Output is correct
66 Correct 9 ms 1968 KB Output is correct
67 Correct 10 ms 2080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4006 ms 7700 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4019 ms 1520 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 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 304 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 0 ms 208 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 0 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 0 ms 336 KB Output is correct
33 Correct 0 ms 336 KB Output is correct
34 Correct 0 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 8 ms 1452 KB Output is correct
37 Correct 17 ms 2336 KB Output is correct
38 Correct 11 ms 1564 KB Output is correct
39 Correct 22 ms 2460 KB Output is correct
40 Correct 10 ms 1564 KB Output is correct
41 Correct 38 ms 4756 KB Output is correct
42 Correct 9 ms 1428 KB Output is correct
43 Correct 11 ms 1440 KB Output is correct
44 Correct 15 ms 1436 KB Output is correct
45 Correct 15 ms 1352 KB Output is correct
46 Correct 9 ms 1488 KB Output is correct
47 Correct 18 ms 2332 KB Output is correct
48 Correct 17 ms 1948 KB Output is correct
49 Correct 10 ms 1560 KB Output is correct
50 Correct 9 ms 1472 KB Output is correct
51 Correct 9 ms 1456 KB Output is correct
52 Correct 18 ms 4736 KB Output is correct
53 Correct 21 ms 5576 KB Output is correct
54 Correct 22 ms 5552 KB Output is correct
55 Correct 9 ms 1980 KB Output is correct
56 Correct 16 ms 1988 KB Output is correct
57 Correct 38 ms 4652 KB Output is correct
58 Correct 32 ms 4912 KB Output is correct
59 Correct 24 ms 4672 KB Output is correct
60 Correct 22 ms 5548 KB Output is correct
61 Correct 34 ms 5520 KB Output is correct
62 Correct 37 ms 5536 KB Output is correct
63 Correct 27 ms 5528 KB Output is correct
64 Correct 15 ms 1968 KB Output is correct
65 Correct 10 ms 1936 KB Output is correct
66 Correct 9 ms 1968 KB Output is correct
67 Correct 10 ms 2080 KB Output is correct
68 Execution timed out 4006 ms 7700 KB Time limit exceeded
69 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4038 ms 2344 KB Time limit exceeded
2 Halted 0 ms 0 KB -