Submission #644026

# Submission time Handle Problem Language Result Execution time Memory
644026 2022-09-23T13:29:47 Z ymm Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
100 / 100
1034 ms 138440 KB
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;

const int N = 1'000'010;

int a[N], n;

int fen[N];
int get(int r)
{
	int ans = 0;
	while (r) {
		ans = max(ans, fen[r]);
		r -= r & -r;
	}
	return ans;
}
void up(int i, int x)
{
	++i;
	while (i <= n) {
		fen[i] = max(fen[i], x);
		i += i & -i;
	}
}

vector<int> A[N];
int ans[N];
vector<int> qry[N];
int r[N], k[N];

int main()
{
	cin.tie(0) -> sync_with_stdio(false);
	int q;
	cin >> n >> q;
	Loop (i,0,n)
		cin >> a[i];
	vector<int> st;
	Loop (i,0,n) {
		while (st.size() && a[st.back()] <= a[i])
			st.pop_back();
		if (st.size())
			A[st.back()].push_back(i);
		st.push_back(i);
	}
	Loop (i,0,q) {
		int l, r, k;
		cin >> l >> r >> k;
		qry[l-1].push_back(i);
		::k[i] = k;
		::r[i] = r;
	}
	LoopR (l,0,n) {
		for (int v : A[l])
			up(v, a[l] + a[v]);
		for (int i : qry[l])
			ans[i] = get(r[i]) <= k[i];
	}
	Loop (i,0,q) {
		cout << ans[i] << '\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 23 ms 47180 KB Output is correct
2 Correct 28 ms 47280 KB Output is correct
3 Correct 23 ms 47312 KB Output is correct
4 Correct 24 ms 47308 KB Output is correct
5 Correct 21 ms 47284 KB Output is correct
6 Correct 22 ms 47316 KB Output is correct
7 Correct 22 ms 47328 KB Output is correct
8 Correct 23 ms 47276 KB Output is correct
9 Correct 22 ms 47348 KB Output is correct
10 Correct 24 ms 47316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 47180 KB Output is correct
2 Correct 28 ms 47280 KB Output is correct
3 Correct 23 ms 47312 KB Output is correct
4 Correct 24 ms 47308 KB Output is correct
5 Correct 21 ms 47284 KB Output is correct
6 Correct 22 ms 47316 KB Output is correct
7 Correct 22 ms 47328 KB Output is correct
8 Correct 23 ms 47276 KB Output is correct
9 Correct 22 ms 47348 KB Output is correct
10 Correct 24 ms 47316 KB Output is correct
11 Correct 23 ms 47504 KB Output is correct
12 Correct 24 ms 47524 KB Output is correct
13 Correct 27 ms 47636 KB Output is correct
14 Correct 25 ms 47716 KB Output is correct
15 Correct 27 ms 47664 KB Output is correct
16 Correct 28 ms 47704 KB Output is correct
17 Correct 25 ms 47568 KB Output is correct
18 Correct 25 ms 47596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 953 ms 103100 KB Output is correct
2 Correct 977 ms 135872 KB Output is correct
3 Correct 961 ms 135668 KB Output is correct
4 Correct 972 ms 135760 KB Output is correct
5 Correct 889 ms 115788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 80 ms 53580 KB Output is correct
2 Correct 77 ms 52736 KB Output is correct
3 Correct 86 ms 51252 KB Output is correct
4 Correct 79 ms 51412 KB Output is correct
5 Correct 75 ms 51572 KB Output is correct
6 Correct 63 ms 50260 KB Output is correct
7 Correct 67 ms 50252 KB Output is correct
8 Correct 65 ms 51464 KB Output is correct
9 Correct 51 ms 49732 KB Output is correct
10 Correct 70 ms 51288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 47180 KB Output is correct
2 Correct 28 ms 47280 KB Output is correct
3 Correct 23 ms 47312 KB Output is correct
4 Correct 24 ms 47308 KB Output is correct
5 Correct 21 ms 47284 KB Output is correct
6 Correct 22 ms 47316 KB Output is correct
7 Correct 22 ms 47328 KB Output is correct
8 Correct 23 ms 47276 KB Output is correct
9 Correct 22 ms 47348 KB Output is correct
10 Correct 24 ms 47316 KB Output is correct
11 Correct 23 ms 47504 KB Output is correct
12 Correct 24 ms 47524 KB Output is correct
13 Correct 27 ms 47636 KB Output is correct
14 Correct 25 ms 47716 KB Output is correct
15 Correct 27 ms 47664 KB Output is correct
16 Correct 28 ms 47704 KB Output is correct
17 Correct 25 ms 47568 KB Output is correct
18 Correct 25 ms 47596 KB Output is correct
19 Correct 189 ms 59572 KB Output is correct
20 Correct 181 ms 59252 KB Output is correct
21 Correct 162 ms 56880 KB Output is correct
22 Correct 165 ms 56928 KB Output is correct
23 Correct 145 ms 56916 KB Output is correct
24 Correct 121 ms 52812 KB Output is correct
25 Correct 128 ms 52872 KB Output is correct
26 Correct 148 ms 53748 KB Output is correct
27 Correct 138 ms 53580 KB Output is correct
28 Correct 137 ms 54084 KB Output is correct
29 Correct 175 ms 55320 KB Output is correct
30 Correct 151 ms 55244 KB Output is correct
31 Correct 161 ms 55196 KB Output is correct
32 Correct 148 ms 55212 KB Output is correct
33 Correct 166 ms 55180 KB Output is correct
34 Correct 131 ms 52432 KB Output is correct
35 Correct 125 ms 52608 KB Output is correct
36 Correct 122 ms 52436 KB Output is correct
37 Correct 137 ms 52428 KB Output is correct
38 Correct 121 ms 52408 KB Output is correct
39 Correct 134 ms 55208 KB Output is correct
40 Correct 119 ms 53432 KB Output is correct
41 Correct 136 ms 54992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 47180 KB Output is correct
2 Correct 28 ms 47280 KB Output is correct
3 Correct 23 ms 47312 KB Output is correct
4 Correct 24 ms 47308 KB Output is correct
5 Correct 21 ms 47284 KB Output is correct
6 Correct 22 ms 47316 KB Output is correct
7 Correct 22 ms 47328 KB Output is correct
8 Correct 23 ms 47276 KB Output is correct
9 Correct 22 ms 47348 KB Output is correct
10 Correct 24 ms 47316 KB Output is correct
11 Correct 23 ms 47504 KB Output is correct
12 Correct 24 ms 47524 KB Output is correct
13 Correct 27 ms 47636 KB Output is correct
14 Correct 25 ms 47716 KB Output is correct
15 Correct 27 ms 47664 KB Output is correct
16 Correct 28 ms 47704 KB Output is correct
17 Correct 25 ms 47568 KB Output is correct
18 Correct 25 ms 47596 KB Output is correct
19 Correct 953 ms 103100 KB Output is correct
20 Correct 977 ms 135872 KB Output is correct
21 Correct 961 ms 135668 KB Output is correct
22 Correct 972 ms 135760 KB Output is correct
23 Correct 889 ms 115788 KB Output is correct
24 Correct 80 ms 53580 KB Output is correct
25 Correct 77 ms 52736 KB Output is correct
26 Correct 86 ms 51252 KB Output is correct
27 Correct 79 ms 51412 KB Output is correct
28 Correct 75 ms 51572 KB Output is correct
29 Correct 63 ms 50260 KB Output is correct
30 Correct 67 ms 50252 KB Output is correct
31 Correct 65 ms 51464 KB Output is correct
32 Correct 51 ms 49732 KB Output is correct
33 Correct 70 ms 51288 KB Output is correct
34 Correct 189 ms 59572 KB Output is correct
35 Correct 181 ms 59252 KB Output is correct
36 Correct 162 ms 56880 KB Output is correct
37 Correct 165 ms 56928 KB Output is correct
38 Correct 145 ms 56916 KB Output is correct
39 Correct 121 ms 52812 KB Output is correct
40 Correct 128 ms 52872 KB Output is correct
41 Correct 148 ms 53748 KB Output is correct
42 Correct 138 ms 53580 KB Output is correct
43 Correct 137 ms 54084 KB Output is correct
44 Correct 175 ms 55320 KB Output is correct
45 Correct 151 ms 55244 KB Output is correct
46 Correct 161 ms 55196 KB Output is correct
47 Correct 148 ms 55212 KB Output is correct
48 Correct 166 ms 55180 KB Output is correct
49 Correct 131 ms 52432 KB Output is correct
50 Correct 125 ms 52608 KB Output is correct
51 Correct 122 ms 52436 KB Output is correct
52 Correct 137 ms 52428 KB Output is correct
53 Correct 121 ms 52408 KB Output is correct
54 Correct 134 ms 55208 KB Output is correct
55 Correct 119 ms 53432 KB Output is correct
56 Correct 136 ms 54992 KB Output is correct
57 Correct 1025 ms 138416 KB Output is correct
58 Correct 1034 ms 138440 KB Output is correct
59 Correct 954 ms 132764 KB Output is correct
60 Correct 943 ms 132680 KB Output is correct
61 Correct 977 ms 132800 KB Output is correct
62 Correct 958 ms 132692 KB Output is correct
63 Correct 642 ms 102184 KB Output is correct
64 Correct 626 ms 102212 KB Output is correct
65 Correct 847 ms 111820 KB Output is correct
66 Correct 909 ms 111716 KB Output is correct
67 Correct 838 ms 112372 KB Output is correct
68 Correct 897 ms 118232 KB Output is correct
69 Correct 901 ms 118112 KB Output is correct
70 Correct 895 ms 117224 KB Output is correct
71 Correct 919 ms 117136 KB Output is correct
72 Correct 891 ms 117144 KB Output is correct
73 Correct 559 ms 100488 KB Output is correct
74 Correct 593 ms 101204 KB Output is correct
75 Correct 547 ms 100256 KB Output is correct
76 Correct 556 ms 100184 KB Output is correct
77 Correct 545 ms 100360 KB Output is correct
78 Correct 751 ms 111112 KB Output is correct
79 Correct 603 ms 96584 KB Output is correct
80 Correct 762 ms 107516 KB Output is correct