#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define pii pair<int,int>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T i, U ...j) {
cout << i << ' ', abc(j...);
}
template <typename T> void printv(T l, T r) {
for (; l != r; ++l)
cout << *l << " \n"[l + 1 == r];
}
#ifdef Doludu
#define test(x...) abc("[" + string(#x) + "]", x)
#define owo freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#else
#define test(x...) void(0)
#define owo ios::sync_with_stdio(false), cin.tie(0)
#endif
int main () {
owo;
int n, q;
cin >> n >> q;
vector <vector <int>> ST(n, vector <int> (18, 0));
for (int i = 0; i < n; ++i)
cin >> ST[i][0];
for (int j = 1; j < 18; ++j) {
for (int i = 0; i + (1 << j) <= n; ++i) {
ST[i][j] = max(ST[i][j - 1], ST[i + (1 << j - 1)][j - 1]);
}
}
while (q--) {
int t, l, r;
cin >> t >> l >> r;
l = max(r - t - 1, 0);
int g = __lg(r - l);
cout << max(ST[l][g], ST[r - (1 << g)][g]) << '\n';
}
}
Compilation message
ho_t5.cpp: In function 'int main()':
ho_t5.cpp:36:48: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
36 | ST[i][j] = max(ST[i][j - 1], ST[i + (1 << j - 1)][j - 1]);
| ~~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
177 ms |
22136 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
165 ms |
21968 KB |
Output is correct |
3 |
Correct |
177 ms |
27212 KB |
Output is correct |
4 |
Correct |
165 ms |
28180 KB |
Output is correct |
5 |
Correct |
185 ms |
27448 KB |
Output is correct |
6 |
Correct |
165 ms |
27640 KB |
Output is correct |
7 |
Correct |
151 ms |
27852 KB |
Output is correct |
8 |
Correct |
175 ms |
27508 KB |
Output is correct |
9 |
Correct |
182 ms |
27208 KB |
Output is correct |
10 |
Correct |
164 ms |
26944 KB |
Output is correct |
11 |
Correct |
181 ms |
28092 KB |
Output is correct |
12 |
Correct |
163 ms |
27780 KB |
Output is correct |
13 |
Correct |
179 ms |
28004 KB |
Output is correct |
14 |
Correct |
174 ms |
27316 KB |
Output is correct |
15 |
Correct |
169 ms |
28088 KB |
Output is correct |
16 |
Correct |
159 ms |
27752 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
165 ms |
20252 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |