Submission #543497

# Submission time Handle Problem Language Result Execution time Memory
543497 2022-03-30T18:25:01 Z fuad27 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
100 / 100
1808 ms 116556 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6 + 10; 
#define ff first
#define ss second
ll fen[N];
ll arr[N];
void upd(int at, ll val) {
	while(at > 0) {
		fen[at] = max(fen[at], val);
		at-=at&(-at);
	}
}
ll get(int r) {
	ll mx = 0;
	while(r < N) {
		mx = max(mx, fen[r]);
		r+=r&(-r);
	}
	return mx;
}
int main () {
	int n, m;
	cin >> n >> m;
	for(int i = 0;i<N;i++)fen[i] = 0;
	for(int i = 1;i<=n;i++)cin >> arr[i];
	vector<pair<pair<ll,ll>, ll>> que[n+1];
	for(int i = 0;i<m;i++) {
		ll l, r, v;
		cin >> l >> r >> v;
		que[r].push_back(make_pair(make_pair(l, v), i));
	}
	ll ans[m];
	vector<int> stk;
	stk.push_back(0);
	for(int i = 1;i<=n;i++) {
		while(stk.size() and arr[stk.back()] <= arr[i])stk.pop_back();
		if(stk.size())upd(stk.back(), arr[stk.back()]+arr[i]);
		stk.push_back(i);
		for(auto q:que[i]) {
			ans[q.ss] = get(q.ff.ff)<=q.ff.ss;
		}
	}
	for(int i = 0;i<m;i++)cout << ans[i] << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8020 KB Output is correct
2 Correct 3 ms 8020 KB Output is correct
3 Correct 3 ms 8148 KB Output is correct
4 Correct 4 ms 8148 KB Output is correct
5 Correct 4 ms 8032 KB Output is correct
6 Correct 4 ms 8148 KB Output is correct
7 Correct 4 ms 8148 KB Output is correct
8 Correct 4 ms 8148 KB Output is correct
9 Correct 4 ms 8148 KB Output is correct
10 Correct 4 ms 8148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8020 KB Output is correct
2 Correct 3 ms 8020 KB Output is correct
3 Correct 3 ms 8148 KB Output is correct
4 Correct 4 ms 8148 KB Output is correct
5 Correct 4 ms 8032 KB Output is correct
6 Correct 4 ms 8148 KB Output is correct
7 Correct 4 ms 8148 KB Output is correct
8 Correct 4 ms 8148 KB Output is correct
9 Correct 4 ms 8148 KB Output is correct
10 Correct 4 ms 8148 KB Output is correct
11 Correct 7 ms 8276 KB Output is correct
12 Correct 9 ms 8296 KB Output is correct
13 Correct 8 ms 8328 KB Output is correct
14 Correct 10 ms 8468 KB Output is correct
15 Correct 10 ms 8404 KB Output is correct
16 Correct 9 ms 8404 KB Output is correct
17 Correct 9 ms 8424 KB Output is correct
18 Correct 8 ms 8436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1711 ms 109696 KB Output is correct
2 Correct 1752 ms 114620 KB Output is correct
3 Correct 1711 ms 114492 KB Output is correct
4 Correct 1756 ms 114540 KB Output is correct
5 Correct 1699 ms 114620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 122 ms 15404 KB Output is correct
2 Correct 113 ms 15652 KB Output is correct
3 Correct 114 ms 15468 KB Output is correct
4 Correct 117 ms 15436 KB Output is correct
5 Correct 117 ms 15460 KB Output is correct
6 Correct 99 ms 15588 KB Output is correct
7 Correct 102 ms 15560 KB Output is correct
8 Correct 108 ms 15136 KB Output is correct
9 Correct 76 ms 12008 KB Output is correct
10 Correct 109 ms 15120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8020 KB Output is correct
2 Correct 3 ms 8020 KB Output is correct
3 Correct 3 ms 8148 KB Output is correct
4 Correct 4 ms 8148 KB Output is correct
5 Correct 4 ms 8032 KB Output is correct
6 Correct 4 ms 8148 KB Output is correct
7 Correct 4 ms 8148 KB Output is correct
8 Correct 4 ms 8148 KB Output is correct
9 Correct 4 ms 8148 KB Output is correct
10 Correct 4 ms 8148 KB Output is correct
11 Correct 7 ms 8276 KB Output is correct
12 Correct 9 ms 8296 KB Output is correct
13 Correct 8 ms 8328 KB Output is correct
14 Correct 10 ms 8468 KB Output is correct
15 Correct 10 ms 8404 KB Output is correct
16 Correct 9 ms 8404 KB Output is correct
17 Correct 9 ms 8424 KB Output is correct
18 Correct 8 ms 8436 KB Output is correct
19 Correct 330 ms 22872 KB Output is correct
20 Correct 323 ms 22856 KB Output is correct
21 Correct 294 ms 23444 KB Output is correct
22 Correct 289 ms 23372 KB Output is correct
23 Correct 288 ms 23348 KB Output is correct
24 Correct 276 ms 23528 KB Output is correct
25 Correct 285 ms 23500 KB Output is correct
26 Correct 308 ms 23080 KB Output is correct
27 Correct 311 ms 23228 KB Output is correct
28 Correct 331 ms 22976 KB Output is correct
29 Correct 389 ms 22968 KB Output is correct
30 Correct 308 ms 22860 KB Output is correct
31 Correct 307 ms 22884 KB Output is correct
32 Correct 306 ms 22860 KB Output is correct
33 Correct 302 ms 22964 KB Output is correct
34 Correct 272 ms 22980 KB Output is correct
35 Correct 269 ms 22920 KB Output is correct
36 Correct 269 ms 23028 KB Output is correct
37 Correct 264 ms 22964 KB Output is correct
38 Correct 272 ms 22988 KB Output is correct
39 Correct 267 ms 22384 KB Output is correct
40 Correct 234 ms 19796 KB Output is correct
41 Correct 252 ms 22284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8020 KB Output is correct
2 Correct 3 ms 8020 KB Output is correct
3 Correct 3 ms 8148 KB Output is correct
4 Correct 4 ms 8148 KB Output is correct
5 Correct 4 ms 8032 KB Output is correct
6 Correct 4 ms 8148 KB Output is correct
7 Correct 4 ms 8148 KB Output is correct
8 Correct 4 ms 8148 KB Output is correct
9 Correct 4 ms 8148 KB Output is correct
10 Correct 4 ms 8148 KB Output is correct
11 Correct 7 ms 8276 KB Output is correct
12 Correct 9 ms 8296 KB Output is correct
13 Correct 8 ms 8328 KB Output is correct
14 Correct 10 ms 8468 KB Output is correct
15 Correct 10 ms 8404 KB Output is correct
16 Correct 9 ms 8404 KB Output is correct
17 Correct 9 ms 8424 KB Output is correct
18 Correct 8 ms 8436 KB Output is correct
19 Correct 1711 ms 109696 KB Output is correct
20 Correct 1752 ms 114620 KB Output is correct
21 Correct 1711 ms 114492 KB Output is correct
22 Correct 1756 ms 114540 KB Output is correct
23 Correct 1699 ms 114620 KB Output is correct
24 Correct 122 ms 15404 KB Output is correct
25 Correct 113 ms 15652 KB Output is correct
26 Correct 114 ms 15468 KB Output is correct
27 Correct 117 ms 15436 KB Output is correct
28 Correct 117 ms 15460 KB Output is correct
29 Correct 99 ms 15588 KB Output is correct
30 Correct 102 ms 15560 KB Output is correct
31 Correct 108 ms 15136 KB Output is correct
32 Correct 76 ms 12008 KB Output is correct
33 Correct 109 ms 15120 KB Output is correct
34 Correct 330 ms 22872 KB Output is correct
35 Correct 323 ms 22856 KB Output is correct
36 Correct 294 ms 23444 KB Output is correct
37 Correct 289 ms 23372 KB Output is correct
38 Correct 288 ms 23348 KB Output is correct
39 Correct 276 ms 23528 KB Output is correct
40 Correct 285 ms 23500 KB Output is correct
41 Correct 308 ms 23080 KB Output is correct
42 Correct 311 ms 23228 KB Output is correct
43 Correct 331 ms 22976 KB Output is correct
44 Correct 389 ms 22968 KB Output is correct
45 Correct 308 ms 22860 KB Output is correct
46 Correct 307 ms 22884 KB Output is correct
47 Correct 306 ms 22860 KB Output is correct
48 Correct 302 ms 22964 KB Output is correct
49 Correct 272 ms 22980 KB Output is correct
50 Correct 269 ms 22920 KB Output is correct
51 Correct 269 ms 23028 KB Output is correct
52 Correct 264 ms 22964 KB Output is correct
53 Correct 272 ms 22988 KB Output is correct
54 Correct 267 ms 22384 KB Output is correct
55 Correct 234 ms 19796 KB Output is correct
56 Correct 252 ms 22284 KB Output is correct
57 Correct 1734 ms 115440 KB Output is correct
58 Correct 1725 ms 115568 KB Output is correct
59 Correct 1659 ms 116360 KB Output is correct
60 Correct 1656 ms 116476 KB Output is correct
61 Correct 1647 ms 116556 KB Output is correct
62 Correct 1668 ms 116352 KB Output is correct
63 Correct 1360 ms 116220 KB Output is correct
64 Correct 1457 ms 116460 KB Output is correct
65 Correct 1756 ms 116396 KB Output is correct
66 Correct 1675 ms 116456 KB Output is correct
67 Correct 1674 ms 116260 KB Output is correct
68 Correct 1734 ms 115764 KB Output is correct
69 Correct 1755 ms 115536 KB Output is correct
70 Correct 1724 ms 115732 KB Output is correct
71 Correct 1685 ms 115576 KB Output is correct
72 Correct 1808 ms 115788 KB Output is correct
73 Correct 1302 ms 110168 KB Output is correct
74 Correct 1351 ms 111024 KB Output is correct
75 Correct 1331 ms 110528 KB Output is correct
76 Correct 1315 ms 110560 KB Output is correct
77 Correct 1356 ms 109928 KB Output is correct
78 Correct 1505 ms 105884 KB Output is correct
79 Correct 1244 ms 84752 KB Output is correct
80 Correct 1417 ms 103068 KB Output is correct