# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1114981 |
2024-11-19T21:23:35 Z |
AdamGS |
Fire (JOI20_ho_t5) |
C++17 |
|
13 ms |
3664 KB |
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct Q{
int l, r, time, index;
};
bool comp(const Q &q1, const Q &q2){
return q1.time<q2.time;
}
int tree[400'007];
void Update(int v, int l, int r, int vl, int vr, int val){
if (vl>r||vr<l) return;
if (vl>=l&&vr<=r){
tree[v]=max(tree[v], val);
return;
}
int mid=(vl+vr)/2;
Update(v*2, l, r, vl, mid, val);
Update(v*2+1, l, r, mid+1, vr, val);
}
int Get(int v){
int out=-1;
while (v>0){
out=max(out, tree[v]);
v/=2;
}
return out;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
for (int i=0;i<400'007;i++) tree[i]=-1;
int n, q;
cin>>n>>q;
int trsize=1;
while (trsize<n) trsize<<=1;
for (int i=0;i<n;i++){
cin>>tree[trsize+i];
}
vector<Q> qv(q);
for (int i=0;i<q;i++){
cin>>qv[i].time>>qv[i].l>>qv[i].r;
qv[i].index=i;
}
sort(qv.begin(), qv.end(), comp);
int t=0;
vector<int> out(q);
for (Q qe:qv){
int tDiff=qe.time-t;
t=qe.time;
for (int i=n-tDiff-1;i>=0;i--){
Update(1, trsize+i, trsize+i+tDiff, trsize, trsize*2-1, Get(trsize+i));
}
out[qe.index]=Get(trsize+qe.l-1);
}
for (int x:out) cout<<x<<'\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1872 KB |
Output is correct |
2 |
Incorrect |
3 ms |
1872 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1872 KB |
Output is correct |
2 |
Runtime error |
13 ms |
3664 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1872 KB |
Output is correct |
2 |
Runtime error |
13 ms |
3664 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
9 ms |
3664 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1872 KB |
Output is correct |
2 |
Incorrect |
3 ms |
1872 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |