답안 #1115033

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

struct Q{
    long long l, r, time, index;
};

bool comp(const Q &q1, const Q &q2){
    return q1.time<q2.time;
}

long long tree[400'007];

void Update(long long v, long long l, long long r, long long vl, long long vr, long long val){
    if (vl>r||vr<l) return;
    if (vl>=l&&vr<=r){
        tree[v]=max(tree[v], val);
        return;
    }
    long long mid=(vl+vr)/2;
    Update(v*2, l, r, vl, mid, val);
    Update(v*2+1, l, r, mid+1, vr, val);
}

long long Get(long long v){
    long long 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 (long long i=0;i<400'007;i++) tree[i]=-1;
    long long n, q;
    cin>>n>>q;
    long long trsize=1;
    while (trsize<n) trsize<<=1;
    for (long long i=0;i<n;i++){
        cin>>tree[trsize+i];
    }
    vector<Q> qv(q);
    for (long long 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);
    long long t=0;
    vector<long long> out(q);
    for (Q qe:qv){
        long long tDiff=qe.time-t;
        t=qe.time;
        for (long long 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 (long long x:out) cout<<x<<'\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3408 KB Output is correct
2 Incorrect 3 ms 3408 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3408 KB Output is correct
2 Runtime error 16 ms 6736 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3408 KB Output is correct
2 Runtime error 17 ms 6736 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 11 ms 6736 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3408 KB Output is correct
2 Incorrect 3 ms 3408 KB Output isn't correct
3 Halted 0 ms 0 KB -