# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
591977 |
2022-07-08T10:20:47 Z |
piOOE |
Fire (JOI20_ho_t5) |
C++17 |
|
1000 ms |
4568 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T>
struct SegTreeMax {
T neutral = 0;
vector <T> t;
int sz;
SegTreeMax() = default;
SegTreeMax(int n, T x = 0) {
sz = n;
neutral = x;
t.assign(sz << 1, x);
}
SegTreeMax(const vector<T> a, T x = 0) {
sz = (int)a.size();
neutral = x;
t.assign(sz << 1, x);
for (int i = 0; i < sz; ++i) {
t[i + sz] = a[i];
}
for (int i = sz - 1; i > 0; --i) {
t[i] = max(t[i << 1], t[i << 1 | 1]);
}
}
void modify(int i, T v) {
int x = i + sz;
t[x] = v;
x >>= 1;
while (x) {
t[x] = max(t[x << 1], t[x << 1 | 1]);
x >>= 1;
}
}
T get(int l, int r) {
l += sz;
r += sz;
T ans = neutral;
while (l < r) {
if (l & 1) {
ans = max(ans, t[l++]);
}
if (r & 1) {
ans = max(ans, t[--r]);
}
l >>= 1;
r >>= 1;
}
return ans;
}
};
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, q;
cin >> n >> q;
vector<int> s(n);
for (int i = 0; i < n; ++i) {
cin >> s[i];
}
SegTreeMax<int> st(s, 0);
while (q--) {
int t, l, r;
cin >> t >> l >> r;
ll ans = 0;
for (int i = l - 1; i < r; ++i) {
ans += st.get(max(0, i - t), i + 1);
}
cout << ans << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
0 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
0 ms |
212 KB |
Output is correct |
31 |
Correct |
1 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
1081 ms |
3284 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
119 ms |
4536 KB |
Output is correct |
3 |
Correct |
116 ms |
4424 KB |
Output is correct |
4 |
Correct |
102 ms |
4552 KB |
Output is correct |
5 |
Correct |
103 ms |
4544 KB |
Output is correct |
6 |
Correct |
132 ms |
4552 KB |
Output is correct |
7 |
Correct |
98 ms |
4552 KB |
Output is correct |
8 |
Correct |
101 ms |
4548 KB |
Output is correct |
9 |
Correct |
107 ms |
4440 KB |
Output is correct |
10 |
Correct |
102 ms |
4436 KB |
Output is correct |
11 |
Correct |
102 ms |
4568 KB |
Output is correct |
12 |
Correct |
110 ms |
4500 KB |
Output is correct |
13 |
Correct |
107 ms |
4552 KB |
Output is correct |
14 |
Correct |
123 ms |
4468 KB |
Output is correct |
15 |
Correct |
99 ms |
4480 KB |
Output is correct |
16 |
Correct |
105 ms |
4436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1088 ms |
3284 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
0 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
0 ms |
212 KB |
Output is correct |
31 |
Correct |
1 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
212 KB |
Output is correct |
33 |
Execution timed out |
1081 ms |
3284 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |