답안 #1115049

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1115049 2024-11-19T23:06:33 Z AdamGS Fire (JOI20_ho_t5) C++17
0 / 100
8 ms 3664 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int tree[400'007];

void Treeify(int trsize){
    for (int i=trsize-1;i>0;i--) tree[i]=max(tree[2*i], tree[2*i+1]);
}

int Get(int v, int l, int r, int vl, int vr){
    if (vl>r||vr<l) return 0;
    if (vl>=l&&vr<=r){
        return tree[v];
    }
    if (tree[vr]==5){
        v=v;
    }
    int mid=(vl+vr)/2;
    int lson=Get(v*2, l, r, vl, mid);
    int rson=Get(v*2+1, l, r, mid+1, vr);
    return max(lson, rson);
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    for (int i=0;i<400'007;i++) tree[i]=0;
    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];
    }
    Treeify(trsize);
    for (int i=1;i<=trsize*2+1;i++) cout<<tree[i]<<" ";
    cout<<'\n';
    for (int qe=0;qe<q;qe++){
        int t, l, r;
        cin>>t>>l>>r;
        l=max(0, l-t);
        cout<<Get(1, trsize+l, trsize+r, trsize, trsize*2+1)<<'\n';
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1872 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1872 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1872 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 3664 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1872 KB Output isn't correct
2 Halted 0 ms 0 KB -