예제 #1
0
int main(){
    int N,x;
    scanf("%d",&N);
    
    SegTree* ST = new SegTree(N);

    for(int i=1;i<=N;i++){
        scanf("%d",&x);
        ST->A[i] = x;
    }

    ST->initialize(1, 1, N);
    int Q;
    scanf("%d",&Q);
    int type, y;

    while(Q--) {
        scanf("%d %d %d", &type, &x, &y);
        if(type==0)
            ST->update(1, 1, N, x, y);
        else {
            Node* ans = ST->query(1, 1, N, x, y);
            printf("%d\n",ans->maxs);
        }
    }
}
예제 #2
0
int main(){
    int N,x;
    
    while( (cin >> N) && N){
        
        SegTree* ST = new SegTree(N);

        for(int i=1;i<=N;i++){
            scanf("%d",&x);
            ST->A[i] = x;
        }

        ST->initialize(1, 1, N);
        cout << getArea(ST, 1, N) << endl;
    }
}