답안 #1006200

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1006200 2024-06-23T14:23:28 Z 0pt1mus23 Sterilizing Spray (JOI15_sterilizing) C++14
80 / 100
5000 ms 5620 KB
#pragma GCC optimize("O3", "inline")
#include <bits/stdc++.h>
using namespace std;
#define ins insert
#define pb push_back
#define int long long int
#define pii pair<int, int>
#define endl '\n'
#define drop(x) cout<<(x)<<endl; return;
#define all(x) x.begin(),x.end()
const int mod = 1e9 +7, sze = 4*100000, inf = 2e18, prime = 23;
int T[sze];
void upd(int node,int idx,int l,int r,int v){
    if(l==r){
        T[node]=v;
        return;
    }
    int mid = (l+r)/2;
    if(idx<=mid){
        upd(2*node,idx,l,mid,v);
    }
    else{
        upd(2*node +1,idx,mid+1,r,v);
    }
    T[node]= T[2*node] + T[2*node +1];

}

void sil(int node,int l,int r,int lx,int rx,int v){
    // cout<<T[node]<<endl;
    if(lx>r || rx<l || T[node]==0){
        return;
    }
    if(lx==rx){
        // cout<<T[node]<<" silirem"<<endl;
        T[node]/=v;
        return;
    }
    int mid = (lx+rx)/2;
    sil(2*node,l,r,lx,mid,v);
    sil(2*node +1,l,r,mid+1,rx,v);
    T[node]= T[2*node] + T[2*node +1];
}
int qry(int node,int l,int r,int lx,int rx){
    if(l>rx || lx>r){
        return 0;
    }
    if(lx>=l && rx<=r){
        return T[node];
    }
    int mid = (lx+rx)/2;
    int left = qry(2*node,l,r,lx,mid);
    int right = qry(2*node +1,l,r,mid+1,rx);
    return left+right;
}

void mal(){
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=0;i<n;i++){
        int x;cin>>x;
        upd(1,i,0,n-1,x);
    }
    while(m--){
        int op;cin>>op;
        if(op==1){
            int idx,v;cin>>idx>>v;
            upd(1,--idx,0,n-1,v);
        }
        else if(op==2){
            int l,r;cin>>l>>r;
            --l;--r;
            sil(1,l,r,0,n-1,k);
            // cout<<"sildim: "<<T[1]<<endl;
        }
        else if(op==3){
            int l,r;cin>>l>>r;
            --l;--r;
            cout<<qry(1,l,r,0,n-1)<<endl;
        }

    }

}  


signed main() {
    cin.tie(0)->sync_with_stdio(0);
    int tt = 1;
    // cin>>tt;
    
    while(tt--){
        mal();        
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 572 KB Output is correct
8 Correct 2 ms 572 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 2 ms 604 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1727 ms 4900 KB Output is correct
2 Correct 1037 ms 4692 KB Output is correct
3 Correct 1632 ms 4632 KB Output is correct
4 Correct 2704 ms 4948 KB Output is correct
5 Correct 3752 ms 5496 KB Output is correct
6 Correct 3657 ms 5456 KB Output is correct
7 Correct 3746 ms 5500 KB Output is correct
8 Correct 3572 ms 5620 KB Output is correct
9 Execution timed out 5003 ms 4436 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 860 KB Output is correct
2 Correct 9 ms 2908 KB Output is correct
3 Correct 12 ms 2908 KB Output is correct
4 Correct 31 ms 3924 KB Output is correct
5 Correct 38 ms 3932 KB Output is correct
6 Correct 39 ms 3924 KB Output is correct
7 Execution timed out 5049 ms 4264 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 4320 KB Output is correct
2 Correct 47 ms 4436 KB Output is correct
3 Correct 45 ms 3924 KB Output is correct
4 Correct 55 ms 4520 KB Output is correct
5 Correct 74 ms 5204 KB Output is correct
6 Correct 72 ms 5204 KB Output is correct
7 Correct 61 ms 5360 KB Output is correct
8 Correct 85 ms 5292 KB Output is correct
9 Correct 78 ms 5204 KB Output is correct
10 Correct 81 ms 5184 KB Output is correct
11 Correct 65 ms 5204 KB Output is correct
12 Correct 107 ms 5204 KB Output is correct