# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
571237 | 2022-06-01T15:21:39 Z | YouAreMyGalaxy | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++17 | 1335 ms | 96168 KB |
//Make CSP great again //Vengeance #include <bits/stdc++.h> #define TASK "TESTCODE" #define Log2(x) 31 - __builtin_clz(x) using namespace std; const int N = 1e6; vector<int> ask[N + 1]; int l[N + 1], k[N + 1], res[N + 1], a[N + 1], n, m; stack<int> st; struct FenwickTree { int Tree[N + 1]; void add(int pos, int val) { for (; pos > 0; pos -= (pos & (-pos))) { Tree[pos] = max(Tree[pos], val); } } int get(int pos) { int ret = 0; for (; pos <= n; pos += (pos & (-pos))) { ret = max(ret, Tree[pos]); } return ret; } } tree; void read() { cin >> n >> m; for (int i = 1; i <= n; ++ i) { cin >> a[i]; } for (int i = 1; i <= m; ++ i) { int r; cin >> l[i] >> r >> k[i]; ask[r].push_back(i); } } void solve() { for (int i = 1; i <= n; ++ i) { while(!st.empty() && a[i] >= a[st.top()]) { st.pop(); } if (!st.empty()) { tree.add(st.top(), a[i] + a[st.top()]); } for (int j : ask[i]) { res[j] = (tree.get(l[j]) <= k[j]); } st.push(i); } for (int i = 1; i <= m; ++ i) { cout << res[i] << '\n'; } } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); if (fopen(TASK".INP", "r")) { freopen(TASK".INP", "r", stdin); //freopen(TASK".OUT", "w", stdout); } int t = 1; bool typetest = false; if (typetest) { cin >> t; } for (int __ = 1; __ <= t; ++ __) { //cout << "Case " << __ << ": "; read(); solve(); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 23764 KB | Output is correct |
2 | Correct | 15 ms | 23764 KB | Output is correct |
3 | Correct | 15 ms | 23828 KB | Output is correct |
4 | Correct | 16 ms | 23748 KB | Output is correct |
5 | Correct | 15 ms | 23816 KB | Output is correct |
6 | Correct | 20 ms | 23764 KB | Output is correct |
7 | Correct | 19 ms | 23828 KB | Output is correct |
8 | Correct | 20 ms | 23760 KB | Output is correct |
9 | Correct | 20 ms | 23800 KB | Output is correct |
10 | Correct | 18 ms | 23796 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 23764 KB | Output is correct |
2 | Correct | 15 ms | 23764 KB | Output is correct |
3 | Correct | 15 ms | 23828 KB | Output is correct |
4 | Correct | 16 ms | 23748 KB | Output is correct |
5 | Correct | 15 ms | 23816 KB | Output is correct |
6 | Correct | 20 ms | 23764 KB | Output is correct |
7 | Correct | 19 ms | 23828 KB | Output is correct |
8 | Correct | 20 ms | 23760 KB | Output is correct |
9 | Correct | 20 ms | 23800 KB | Output is correct |
10 | Correct | 18 ms | 23796 KB | Output is correct |
11 | Correct | 18 ms | 23944 KB | Output is correct |
12 | Correct | 19 ms | 24012 KB | Output is correct |
13 | Correct | 19 ms | 24200 KB | Output is correct |
14 | Correct | 23 ms | 24160 KB | Output is correct |
15 | Correct | 19 ms | 24184 KB | Output is correct |
16 | Correct | 17 ms | 24020 KB | Output is correct |
17 | Correct | 17 ms | 24088 KB | Output is correct |
18 | Correct | 20 ms | 24032 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1201 ms | 95072 KB | Output is correct |
2 | Correct | 1179 ms | 96168 KB | Output is correct |
3 | Correct | 1272 ms | 96152 KB | Output is correct |
4 | Correct | 1122 ms | 96160 KB | Output is correct |
5 | Correct | 985 ms | 92236 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 100 ms | 29508 KB | Output is correct |
2 | Correct | 68 ms | 28720 KB | Output is correct |
3 | Correct | 90 ms | 28932 KB | Output is correct |
4 | Correct | 96 ms | 29064 KB | Output is correct |
5 | Correct | 98 ms | 29152 KB | Output is correct |
6 | Correct | 68 ms | 27968 KB | Output is correct |
7 | Correct | 65 ms | 27924 KB | Output is correct |
8 | Correct | 94 ms | 28808 KB | Output is correct |
9 | Correct | 52 ms | 27016 KB | Output is correct |
10 | Correct | 90 ms | 28720 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 23764 KB | Output is correct |
2 | Correct | 15 ms | 23764 KB | Output is correct |
3 | Correct | 15 ms | 23828 KB | Output is correct |
4 | Correct | 16 ms | 23748 KB | Output is correct |
5 | Correct | 15 ms | 23816 KB | Output is correct |
6 | Correct | 20 ms | 23764 KB | Output is correct |
7 | Correct | 19 ms | 23828 KB | Output is correct |
8 | Correct | 20 ms | 23760 KB | Output is correct |
9 | Correct | 20 ms | 23800 KB | Output is correct |
10 | Correct | 18 ms | 23796 KB | Output is correct |
11 | Correct | 18 ms | 23944 KB | Output is correct |
12 | Correct | 19 ms | 24012 KB | Output is correct |
13 | Correct | 19 ms | 24200 KB | Output is correct |
14 | Correct | 23 ms | 24160 KB | Output is correct |
15 | Correct | 19 ms | 24184 KB | Output is correct |
16 | Correct | 17 ms | 24020 KB | Output is correct |
17 | Correct | 17 ms | 24088 KB | Output is correct |
18 | Correct | 20 ms | 24032 KB | Output is correct |
19 | Correct | 197 ms | 37900 KB | Output is correct |
20 | Correct | 188 ms | 37880 KB | Output is correct |
21 | Correct | 141 ms | 36056 KB | Output is correct |
22 | Correct | 166 ms | 36084 KB | Output is correct |
23 | Correct | 152 ms | 36044 KB | Output is correct |
24 | Correct | 188 ms | 35024 KB | Output is correct |
25 | Correct | 182 ms | 35024 KB | Output is correct |
26 | Correct | 190 ms | 35928 KB | Output is correct |
27 | Correct | 163 ms | 35916 KB | Output is correct |
28 | Correct | 201 ms | 36208 KB | Output is correct |
29 | Correct | 210 ms | 37180 KB | Output is correct |
30 | Correct | 212 ms | 37164 KB | Output is correct |
31 | Correct | 195 ms | 37100 KB | Output is correct |
32 | Correct | 219 ms | 37104 KB | Output is correct |
33 | Correct | 224 ms | 37032 KB | Output is correct |
34 | Correct | 177 ms | 34656 KB | Output is correct |
35 | Correct | 170 ms | 34840 KB | Output is correct |
36 | Correct | 199 ms | 34504 KB | Output is correct |
37 | Correct | 130 ms | 34444 KB | Output is correct |
38 | Correct | 135 ms | 34708 KB | Output is correct |
39 | Correct | 171 ms | 35556 KB | Output is correct |
40 | Correct | 157 ms | 34100 KB | Output is correct |
41 | Correct | 176 ms | 35104 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 23764 KB | Output is correct |
2 | Correct | 15 ms | 23764 KB | Output is correct |
3 | Correct | 15 ms | 23828 KB | Output is correct |
4 | Correct | 16 ms | 23748 KB | Output is correct |
5 | Correct | 15 ms | 23816 KB | Output is correct |
6 | Correct | 20 ms | 23764 KB | Output is correct |
7 | Correct | 19 ms | 23828 KB | Output is correct |
8 | Correct | 20 ms | 23760 KB | Output is correct |
9 | Correct | 20 ms | 23800 KB | Output is correct |
10 | Correct | 18 ms | 23796 KB | Output is correct |
11 | Correct | 18 ms | 23944 KB | Output is correct |
12 | Correct | 19 ms | 24012 KB | Output is correct |
13 | Correct | 19 ms | 24200 KB | Output is correct |
14 | Correct | 23 ms | 24160 KB | Output is correct |
15 | Correct | 19 ms | 24184 KB | Output is correct |
16 | Correct | 17 ms | 24020 KB | Output is correct |
17 | Correct | 17 ms | 24088 KB | Output is correct |
18 | Correct | 20 ms | 24032 KB | Output is correct |
19 | Correct | 1201 ms | 95072 KB | Output is correct |
20 | Correct | 1179 ms | 96168 KB | Output is correct |
21 | Correct | 1272 ms | 96152 KB | Output is correct |
22 | Correct | 1122 ms | 96160 KB | Output is correct |
23 | Correct | 985 ms | 92236 KB | Output is correct |
24 | Correct | 100 ms | 29508 KB | Output is correct |
25 | Correct | 68 ms | 28720 KB | Output is correct |
26 | Correct | 90 ms | 28932 KB | Output is correct |
27 | Correct | 96 ms | 29064 KB | Output is correct |
28 | Correct | 98 ms | 29152 KB | Output is correct |
29 | Correct | 68 ms | 27968 KB | Output is correct |
30 | Correct | 65 ms | 27924 KB | Output is correct |
31 | Correct | 94 ms | 28808 KB | Output is correct |
32 | Correct | 52 ms | 27016 KB | Output is correct |
33 | Correct | 90 ms | 28720 KB | Output is correct |
34 | Correct | 197 ms | 37900 KB | Output is correct |
35 | Correct | 188 ms | 37880 KB | Output is correct |
36 | Correct | 141 ms | 36056 KB | Output is correct |
37 | Correct | 166 ms | 36084 KB | Output is correct |
38 | Correct | 152 ms | 36044 KB | Output is correct |
39 | Correct | 188 ms | 35024 KB | Output is correct |
40 | Correct | 182 ms | 35024 KB | Output is correct |
41 | Correct | 190 ms | 35928 KB | Output is correct |
42 | Correct | 163 ms | 35916 KB | Output is correct |
43 | Correct | 201 ms | 36208 KB | Output is correct |
44 | Correct | 210 ms | 37180 KB | Output is correct |
45 | Correct | 212 ms | 37164 KB | Output is correct |
46 | Correct | 195 ms | 37100 KB | Output is correct |
47 | Correct | 219 ms | 37104 KB | Output is correct |
48 | Correct | 224 ms | 37032 KB | Output is correct |
49 | Correct | 177 ms | 34656 KB | Output is correct |
50 | Correct | 170 ms | 34840 KB | Output is correct |
51 | Correct | 199 ms | 34504 KB | Output is correct |
52 | Correct | 130 ms | 34444 KB | Output is correct |
53 | Correct | 135 ms | 34708 KB | Output is correct |
54 | Correct | 171 ms | 35556 KB | Output is correct |
55 | Correct | 157 ms | 34100 KB | Output is correct |
56 | Correct | 176 ms | 35104 KB | Output is correct |
57 | Correct | 1202 ms | 95116 KB | Output is correct |
58 | Correct | 1335 ms | 95036 KB | Output is correct |
59 | Correct | 1180 ms | 90860 KB | Output is correct |
60 | Correct | 1145 ms | 90848 KB | Output is correct |
61 | Correct | 1281 ms | 90900 KB | Output is correct |
62 | Correct | 1133 ms | 90848 KB | Output is correct |
63 | Correct | 866 ms | 79316 KB | Output is correct |
64 | Correct | 946 ms | 79300 KB | Output is correct |
65 | Correct | 1098 ms | 86416 KB | Output is correct |
66 | Correct | 1183 ms | 86368 KB | Output is correct |
67 | Correct | 1198 ms | 86784 KB | Output is correct |
68 | Correct | 1262 ms | 91180 KB | Output is correct |
69 | Correct | 1317 ms | 90740 KB | Output is correct |
70 | Correct | 1202 ms | 90492 KB | Output is correct |
71 | Correct | 1174 ms | 90468 KB | Output is correct |
72 | Correct | 1128 ms | 90472 KB | Output is correct |
73 | Correct | 783 ms | 77136 KB | Output is correct |
74 | Correct | 937 ms | 78140 KB | Output is correct |
75 | Correct | 849 ms | 77200 KB | Output is correct |
76 | Correct | 832 ms | 77224 KB | Output is correct |
77 | Correct | 927 ms | 76988 KB | Output is correct |
78 | Correct | 1071 ms | 84484 KB | Output is correct |
79 | Correct | 776 ms | 74260 KB | Output is correct |
80 | Correct | 1049 ms | 81000 KB | Output is correct |