Submission #952597

# Submission time Handle Problem Language Result Execution time Memory
952597 2024-03-24T10:49:41 Z aliyousef Sterilizing Spray (JOI15_sterilizing) C++17
5 / 100
5000 ms 4740 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=1<<(int)(ceil(log2(200001)));
int t[N*2+5]={};
struct st{
    /*void update(int l,int r,int ql,int qr,int i,int v){
        if(l>qr||r<ql)return;
        if(l>=ql&&r<=qr){
            t[i]/=v;
            return;
        }
        int m=(r+l)/2;
        update(l,m,ql,qr,i*2,v);
        update(m+1,r,ql,qr,i*2+1,v);
    }*/
    void update1(int i,int v){
        i+=N;
        t[i]=v;
        while(i>0){
            i/=2;
            t[i]=t[i*2]+t[i*2+1];
        }
    }
    int query(int l,int r,int ql,int qr,int i){
        if(l>qr||r<ql)return 0;
        if(l>=ql&&r<=qr)return t[i];
        int m=(r+l)/2;
        return query(l,m,ql,qr,i*2)+query(m+1,r,ql,qr,i*2+1);
    }
    int _query(int l,int r){
        return query(0,N-1,l,r,1);
    }
    /*void _update(int l,int r,int v){
        update(0,N-1,l,r,1,v);
    }*/
};
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    cout.tie(0)->sync_with_stdio(0);
    int n,q,k;
    cin>>n>>q>>k;
    int a[n];
    st sg;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sg.update1(i,a[i]);
    }
    while(q--){
        int tybe;
        cin>>tybe;
        if(tybe==1){
            int a,b;
            cin>>a>>b;
            a--;
            sg.update1(a,b);
        }
        else if(tybe==2){
            int l,r;
            cin>>l>>r;
            l--;r--;
            for(int i=l;i<=r;i++){
                sg.update1(i,t[i+N]/k);
            }
        }
        else{
            int l,r;
            cin>>l>>r;
            l--;r--;
            cout<<sg._query(l,r)<<'\n';
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2392 KB Output is correct
2 Correct 4 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 9 ms 2604 KB Output is correct
5 Correct 18 ms 2396 KB Output is correct
6 Correct 24 ms 2396 KB Output is correct
7 Correct 19 ms 2520 KB Output is correct
8 Correct 22 ms 2396 KB Output is correct
9 Correct 19 ms 2392 KB Output is correct
10 Correct 20 ms 2392 KB Output is correct
11 Correct 19 ms 2392 KB Output is correct
12 Correct 20 ms 2632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5075 ms 4604 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 490 ms 2896 KB Output is correct
2 Correct 1286 ms 3360 KB Output is correct
3 Correct 2045 ms 3576 KB Output is correct
4 Correct 4598 ms 3932 KB Output is correct
5 Execution timed out 5036 ms 4740 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5045 ms 4728 KB Time limit exceeded
2 Halted 0 ms 0 KB -