# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
485065 |
2021-11-06T02:19:36 Z |
socho |
Fire (JOI20_ho_t5) |
C++14 |
|
149 ms |
13644 KB |
/*
Going for Subtask 3
*/
#include <bits/stdc++.h>
using namespace std;
void fast() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
}
void ran() {
srand(chrono::steady_clock::now().time_since_epoch().count());
}
long long get_rand() {
long long a = rand();
long long b = rand();
return a * (RAND_MAX + 1ll) + b;
}
void usaco() {
freopen("problem.in", "r", stdin);
freopen("problem.out", "w", stdout);
}
template<typename T>
using min_pq = priority_queue<T, vector<T>, greater<T>>;
#define endl '\n'
// #define double long double
#define int long long
// const int MOD = 1000 * 1000 * 1000 + 7;
// const int MOD = 998244353;
// #define cerr if(0) cerr
#define debug(x) cerr << #x << ": " << x << endl;
int n, q;
const int MXN = 200005;
int arr[MXN];
int narr[MXN];
int seg[MXN * 4];
void build(int ind, int l, int r) {
if (l == r) {
seg[ind] = arr[l];
return;
}
int m = (l + r) / 2;
build(ind*2, l, m);
build(ind*2+1, m+1, r);
seg[ind] = max(seg[ind*2], seg[ind*2+1]);
}
int query(int ind, int l, int r, int ql, int qr) {
if (ql <= l && r <= qr) return seg[ind];
if (ql > r || qr < l) return INT_MIN;
int m = (l + r) / 2;
return max(query(ind*2, l, m, ql, qr), query(ind*2+1, m+1, r, ql, qr));
}
signed main() {
ran(); fast();
cin >> n >> q;
for (int i=1; i<=n; i++) cin >> arr[i];
build(1, 1, n);
int tm = -1;
// vector<pair<int, pair<int, int>>> proc;
for (int i=0; i<q; i++) {
int t, l, r;
cin >> t >> l >> r;
cout << query(1, 1, n, max(1ll, l-t), r) << endl;
}
}
Compilation message
ho_t5.cpp: In function 'int main()':
ho_t5.cpp:64:6: warning: unused variable 'tm' [-Wunused-variable]
64 | int tm = -1;
| ^~
ho_t5.cpp: In function 'void usaco()':
ho_t5.cpp:18:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
18 | freopen("problem.in", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
ho_t5.cpp:19:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
19 | freopen("problem.out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
129 ms |
7816 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
137 ms |
7876 KB |
Output is correct |
3 |
Correct |
138 ms |
13332 KB |
Output is correct |
4 |
Correct |
140 ms |
13608 KB |
Output is correct |
5 |
Correct |
138 ms |
13316 KB |
Output is correct |
6 |
Correct |
148 ms |
13380 KB |
Output is correct |
7 |
Correct |
131 ms |
13436 KB |
Output is correct |
8 |
Correct |
146 ms |
13592 KB |
Output is correct |
9 |
Correct |
134 ms |
13392 KB |
Output is correct |
10 |
Correct |
131 ms |
13300 KB |
Output is correct |
11 |
Correct |
137 ms |
13644 KB |
Output is correct |
12 |
Correct |
131 ms |
13380 KB |
Output is correct |
13 |
Correct |
135 ms |
13532 KB |
Output is correct |
14 |
Correct |
133 ms |
13424 KB |
Output is correct |
15 |
Correct |
149 ms |
13608 KB |
Output is correct |
16 |
Correct |
137 ms |
13352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
115 ms |
6212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |