답안 #501670

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
501670 2022-01-04T09:39:45 Z BY_KUTBILIM Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
100 / 100
2255 ms 87840 KB
#include <bits/stdc++.h>
using namespace std;
int n, m, w[1000001], a[5000001], l[1000001], pos, val, x, y;
bool f[1000001];

struct Query {int id, l, k; };
vector<Query> q[1000001];

stack<int> s;

void update(int nod, int l, int r){
	if(l == r)a[nod] = max(a[nod], val);
	else{
		int m = (l + r) / 2;
		if(pos <= m)update(2*nod, l, m);
		else update(2*nod+1,m+1, r);
		a[nod] = max(a[2*nod], a[2*nod+1]);
	}
}
int query(int nod, int l, int r){
	if(x <= l and r <= y)return a[nod];
	int m = (l + r) / 2, res = 0;
	if(x <= m)res = max(res, query(2*nod,l, m));
	if(m < y)res = max(res, query(2*nod+1,m+1,r));
	return res;
}
void solve(){
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		cin >> w[i];
	}
	for(int i = 1, r, l, k; i <= m; i++){
		cin >> l >> r >> k;
		q[r].push_back({i, l, k});
	}
	for(int i = 1; i <= n; i++){
		l[i] = i;
		for(; !s.empty() && w[i] >= w[s.top()]; s.pop())
			l[i] = l[s.top()];
		s.push(i);
	}
	for(int i = 1; i <= n; i++){
		if(l[i] > 1){
			pos = l[i] - 1;
			val = w[i] + w[pos];
			update(1, 1, n);
		}
		for(auto j : q[i]){
			x = j.l, y = i;
			f[j.id] = (j.k >= query(1, 1, n));
		}
	}
	for(int i = 1; i <= m; i++){
		cout << f[i] << '\n';
	}
}

int main(){
	solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 23760 KB Output is correct
2 Correct 11 ms 23760 KB Output is correct
3 Correct 12 ms 23756 KB Output is correct
4 Correct 14 ms 23780 KB Output is correct
5 Correct 12 ms 23784 KB Output is correct
6 Correct 14 ms 23756 KB Output is correct
7 Correct 13 ms 23764 KB Output is correct
8 Correct 12 ms 23792 KB Output is correct
9 Correct 11 ms 23756 KB Output is correct
10 Correct 11 ms 23792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 23760 KB Output is correct
2 Correct 11 ms 23760 KB Output is correct
3 Correct 12 ms 23756 KB Output is correct
4 Correct 14 ms 23780 KB Output is correct
5 Correct 12 ms 23784 KB Output is correct
6 Correct 14 ms 23756 KB Output is correct
7 Correct 13 ms 23764 KB Output is correct
8 Correct 12 ms 23792 KB Output is correct
9 Correct 11 ms 23756 KB Output is correct
10 Correct 11 ms 23792 KB Output is correct
11 Correct 16 ms 23956 KB Output is correct
12 Correct 23 ms 24032 KB Output is correct
13 Correct 25 ms 24080 KB Output is correct
14 Correct 23 ms 24160 KB Output is correct
15 Correct 22 ms 24140 KB Output is correct
16 Correct 21 ms 24004 KB Output is correct
17 Correct 18 ms 24032 KB Output is correct
18 Correct 22 ms 24012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2243 ms 70236 KB Output is correct
2 Correct 2228 ms 86684 KB Output is correct
3 Correct 2223 ms 86820 KB Output is correct
4 Correct 2255 ms 86804 KB Output is correct
5 Correct 1949 ms 78696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 162 ms 29420 KB Output is correct
2 Correct 154 ms 29148 KB Output is correct
3 Correct 146 ms 28228 KB Output is correct
4 Correct 146 ms 28308 KB Output is correct
5 Correct 149 ms 28380 KB Output is correct
6 Correct 127 ms 27920 KB Output is correct
7 Correct 128 ms 28008 KB Output is correct
8 Correct 143 ms 28300 KB Output is correct
9 Correct 86 ms 26876 KB Output is correct
10 Correct 133 ms 28284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 23760 KB Output is correct
2 Correct 11 ms 23760 KB Output is correct
3 Correct 12 ms 23756 KB Output is correct
4 Correct 14 ms 23780 KB Output is correct
5 Correct 12 ms 23784 KB Output is correct
6 Correct 14 ms 23756 KB Output is correct
7 Correct 13 ms 23764 KB Output is correct
8 Correct 12 ms 23792 KB Output is correct
9 Correct 11 ms 23756 KB Output is correct
10 Correct 11 ms 23792 KB Output is correct
11 Correct 16 ms 23956 KB Output is correct
12 Correct 23 ms 24032 KB Output is correct
13 Correct 25 ms 24080 KB Output is correct
14 Correct 23 ms 24160 KB Output is correct
15 Correct 22 ms 24140 KB Output is correct
16 Correct 21 ms 24004 KB Output is correct
17 Correct 18 ms 24032 KB Output is correct
18 Correct 22 ms 24012 KB Output is correct
19 Correct 389 ms 33636 KB Output is correct
20 Correct 403 ms 33576 KB Output is correct
21 Correct 379 ms 33204 KB Output is correct
22 Correct 368 ms 33144 KB Output is correct
23 Correct 395 ms 33120 KB Output is correct
24 Correct 329 ms 31088 KB Output is correct
25 Correct 336 ms 31096 KB Output is correct
26 Correct 337 ms 31372 KB Output is correct
27 Correct 346 ms 31236 KB Output is correct
28 Correct 358 ms 31236 KB Output is correct
29 Correct 365 ms 31600 KB Output is correct
30 Correct 368 ms 31556 KB Output is correct
31 Correct 368 ms 31580 KB Output is correct
32 Correct 382 ms 31584 KB Output is correct
33 Correct 362 ms 31584 KB Output is correct
34 Correct 365 ms 30748 KB Output is correct
35 Correct 310 ms 30768 KB Output is correct
36 Correct 322 ms 30796 KB Output is correct
37 Correct 310 ms 30748 KB Output is correct
38 Correct 321 ms 30788 KB Output is correct
39 Correct 329 ms 31908 KB Output is correct
40 Correct 301 ms 30444 KB Output is correct
41 Correct 350 ms 31256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 23760 KB Output is correct
2 Correct 11 ms 23760 KB Output is correct
3 Correct 12 ms 23756 KB Output is correct
4 Correct 14 ms 23780 KB Output is correct
5 Correct 12 ms 23784 KB Output is correct
6 Correct 14 ms 23756 KB Output is correct
7 Correct 13 ms 23764 KB Output is correct
8 Correct 12 ms 23792 KB Output is correct
9 Correct 11 ms 23756 KB Output is correct
10 Correct 11 ms 23792 KB Output is correct
11 Correct 16 ms 23956 KB Output is correct
12 Correct 23 ms 24032 KB Output is correct
13 Correct 25 ms 24080 KB Output is correct
14 Correct 23 ms 24160 KB Output is correct
15 Correct 22 ms 24140 KB Output is correct
16 Correct 21 ms 24004 KB Output is correct
17 Correct 18 ms 24032 KB Output is correct
18 Correct 22 ms 24012 KB Output is correct
19 Correct 2243 ms 70236 KB Output is correct
20 Correct 2228 ms 86684 KB Output is correct
21 Correct 2223 ms 86820 KB Output is correct
22 Correct 2255 ms 86804 KB Output is correct
23 Correct 1949 ms 78696 KB Output is correct
24 Correct 162 ms 29420 KB Output is correct
25 Correct 154 ms 29148 KB Output is correct
26 Correct 146 ms 28228 KB Output is correct
27 Correct 146 ms 28308 KB Output is correct
28 Correct 149 ms 28380 KB Output is correct
29 Correct 127 ms 27920 KB Output is correct
30 Correct 128 ms 28008 KB Output is correct
31 Correct 143 ms 28300 KB Output is correct
32 Correct 86 ms 26876 KB Output is correct
33 Correct 133 ms 28284 KB Output is correct
34 Correct 389 ms 33636 KB Output is correct
35 Correct 403 ms 33576 KB Output is correct
36 Correct 379 ms 33204 KB Output is correct
37 Correct 368 ms 33144 KB Output is correct
38 Correct 395 ms 33120 KB Output is correct
39 Correct 329 ms 31088 KB Output is correct
40 Correct 336 ms 31096 KB Output is correct
41 Correct 337 ms 31372 KB Output is correct
42 Correct 346 ms 31236 KB Output is correct
43 Correct 358 ms 31236 KB Output is correct
44 Correct 365 ms 31600 KB Output is correct
45 Correct 368 ms 31556 KB Output is correct
46 Correct 368 ms 31580 KB Output is correct
47 Correct 382 ms 31584 KB Output is correct
48 Correct 362 ms 31584 KB Output is correct
49 Correct 365 ms 30748 KB Output is correct
50 Correct 310 ms 30768 KB Output is correct
51 Correct 322 ms 30796 KB Output is correct
52 Correct 310 ms 30748 KB Output is correct
53 Correct 321 ms 30788 KB Output is correct
54 Correct 329 ms 31908 KB Output is correct
55 Correct 301 ms 30444 KB Output is correct
56 Correct 350 ms 31256 KB Output is correct
57 Correct 2129 ms 69744 KB Output is correct
58 Correct 2241 ms 69880 KB Output is correct
59 Correct 2053 ms 68220 KB Output is correct
60 Correct 2058 ms 68280 KB Output is correct
61 Correct 2133 ms 68148 KB Output is correct
62 Correct 2058 ms 68340 KB Output is correct
63 Correct 1733 ms 58204 KB Output is correct
64 Correct 1612 ms 58288 KB Output is correct
65 Correct 1945 ms 59836 KB Output is correct
66 Correct 1972 ms 60188 KB Output is correct
67 Correct 1915 ms 87840 KB Output is correct
68 Correct 1969 ms 61652 KB Output is correct
69 Correct 1939 ms 61672 KB Output is correct
70 Correct 2013 ms 62264 KB Output is correct
71 Correct 1915 ms 62132 KB Output is correct
72 Correct 1895 ms 61408 KB Output is correct
73 Correct 1527 ms 56660 KB Output is correct
74 Correct 1554 ms 59968 KB Output is correct
75 Correct 1528 ms 59672 KB Output is correct
76 Correct 1553 ms 58704 KB Output is correct
77 Correct 1529 ms 58212 KB Output is correct
78 Correct 1650 ms 61652 KB Output is correct
79 Correct 1337 ms 53524 KB Output is correct
80 Correct 1551 ms 59640 KB Output is correct