답안 #954403

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
954403 2024-03-27T19:31:45 Z ziyad_alharbi Sterilizing Spray (JOI15_sterilizing) C++17
0 / 100
5000 ms 6448 KB
#include <bits/stdc++.h>
using namespace std;
vector<long long>sg,a(100005);
int n,sz;
void is()
{
    for(sz=1;sz<n;sz*=2);
    sg.resize(sz*2,0);
}
void up(int i,long long v)
{
    i+=sz;
    sg[i]=v;
    for(i/=2;i>0;i/=2)
    {
        sg[i]=sg[i*2]+sg[i*2+1];
    }
}
long long q(int v,int lw,int h,int l,int r)
{
    if(lw<=l&&r<=h)return sg[v];
    else if(l>=h||lw>=r)return 0;
    else
    {
        int m=(l+r)/2;
        return q(v*2,lw,h,l,m)+q(v*2+1,lw,h,m,r);
    }
}
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
    {
        int qr,k;
        cin>>n>>qr>>k;
        is();
        for(int x=0;x<n;x++)
        {
            cin>>a[x];
            up(x,a[x]);
        }
        
        if(k==1)
        {
            while(qr--)
            {
                int t,l,r;
                cin>>t>>l>>r;
                if(t==1)up(l-1,r);
                if(t==3)cout<<q(1,l-1,r,0,sz);
            }
        }
        else
        {
            while(qr--)
            {
                int t,l,r;
                cin>>t>>l>>r;
                if(t==1)a[l-1]=r;
                if(t==2)
                {
                    for(int x=l-1;x<r;x++)a[x]/=k;
                }
                if(t==3)
                {
                    long long s=0;
                    for(int x=l-1;x<r;x++)s+=a[x];
                    cout<<s<<'\n';
                }
            }
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Incorrect 2 ms 1116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 34 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 113 ms 1616 KB Output is correct
2 Correct 279 ms 2540 KB Output is correct
3 Correct 438 ms 2636 KB Output is correct
4 Correct 963 ms 3164 KB Output is correct
5 Correct 3964 ms 4856 KB Output is correct
6 Correct 3935 ms 4852 KB Output is correct
7 Incorrect 36 ms 4688 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1443 ms 2564 KB Output is correct
2 Correct 1659 ms 4316 KB Output is correct
3 Correct 884 ms 3664 KB Output is correct
4 Correct 1217 ms 3588 KB Output is correct
5 Correct 3973 ms 6128 KB Output is correct
6 Correct 4014 ms 5972 KB Output is correct
7 Correct 3999 ms 6448 KB Output is correct
8 Correct 3934 ms 5908 KB Output is correct
9 Execution timed out 5037 ms 4856 KB Time limit exceeded
10 Halted 0 ms 0 KB -