답안 #953669

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
953669 2024-03-26T12:25:30 Z m5588ohammed Sterilizing Spray (JOI15_sterilizing) C++14
0 / 100
78 ms 12760 KB
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
#define int long long
int Tree[3000000];
int N=(1<<((int)(log2(600000)+1)));
int l,r;
int solve(int l1,int r1,int i){
    if(l1>r||r1<l) return 0;
    if(l1>=l&&r1<=r){ 
        return Tree[i];
    }
    return solve(l1,(r1+l1)/2,i*2)+solve(((l1+r1)/2)+1,r1,i*2+1);
}
signed main()
{
    int n,k,q;
    cin>>n>>q>>k;
    int arr[n+1]={};
    for(int i=0;i<n;i++){
        cin>>arr[i];
        Tree[i+N]=arr[i];
    }
    for(int i=N-1;i>=1;i--) Tree[i]=Tree[i*2]+Tree[i*2+1];
    
    
    if(k==1){
        while(q--){
            int type;
            cin>>type;
            if(type==1){
                int indx,b;
                cin>>indx>>b;
                indx--;
                arr[indx]=b;
                indx+=N;
                Tree[indx]=b;
                indx/=2;
                while(indx!=0){
                    Tree[indx]=Tree[indx*2]+Tree[indx*2+1];
                    indx/=2;
                }
            }
            if(type==3){
                cin>>l>>r;
                l--;
                r--;
                cout<<solve(0,N-1,1)<<endl;
            }    
        }
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 8792 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 78 ms 12760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 8792 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 11100 KB Output isn't correct
2 Halted 0 ms 0 KB -