Submission #872381

# Submission time Handle Problem Language Result Execution time Memory
872381 2023-11-13T03:36:34 Z 12345678 Sterilizing Spray (JOI15_sterilizing) C++17
5 / 100
5000 ms 4072 KB
#include <bits/stdc++.h>

using namespace std;

const long long nx=1e5+5, kx=33;

#define ll long long

ll n, q, k, a[nx], p[kx], x, l, r, t;

struct segtree
{
    struct node
    {
        ll cnt, lz, sm[kx];
    } d[4*nx];
    void pushlz(int l, int r, int i)
    {
        d[i].cnt=min(d[i].cnt+d[i].lz, kx);
        if (l==r) return void(d[i].lz=0);
        d[2*i].lz+=d[i].lz;
        d[2*i+1].lz+=d[i].lz;
        return void(d[i].lz=0);
    }
    void update(int l, int r, int i, int idx, int vl)
    {
        pushlz(l, r, i);
        if (r<idx||idx<l) return;
        if (l==r)
        {
            for (int j=0; j<kx; j++) d[i].sm[j]=vl/p[j];
            d[i].cnt=0;
            return;
        }
        int md=(l+r)/2;
        update(l, md, 2*i, idx, vl);
        update(md+1, r, 2*i+1, idx, vl);
        for (int j=0; j<kx; j++) d[i].sm[j]=d[2*i].sm[min(d[2*i].cnt+j, kx-1)]+d[2*i+1].sm[min(d[2*i+1].cnt+j, kx-1)];
        d[i].cnt=0;
    }
    void update2(int l, int r, int i, int ql, int qr)
    {
        pushlz(l, r, i);
        if (qr<l||r<ql) return;
        if (ql<=l&&r<=qr) return d[i].lz++, pushlz(l, r, i), void();
        int md=(l+r)/2;
        update2(l, md, 2*i, ql, qr);
        update2(md+1, r, 2*i+1, ql, qr);
    }
    ll query(int l, int r, int i, int ql, int qr)
    {
        pushlz(l, r, i);
        if (qr<l||r<ql) return 0;
        if (ql<=l&&r<=qr) return d[i].sm[d[i].cnt];
        int md=(l+r)/2;
        return query(l, md, 2*i, ql, qr)+query(md+1, r, 2*i+1, ql, qr);
    }
} s;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>q>>k;
    for (int i=1; i<=n; i++) cin>>a[i];
    while (q--)
    {
        cin>>t;
        if (t==1) cin>>x>>a[x];
        if (t==2) 
        {
            cin>>l>>r;
            for (int i=l; i<=r; i++) a[i]/=k;
        }
        if (t==3) 
        {
            cin>>l>>r;
            ll res=0;
            for (int i=l; i<=r; i++) res+=a[i];
            cout<<res<<'\n';
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 480 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 5 ms 572 KB Output is correct
6 Correct 5 ms 348 KB Output is correct
7 Correct 5 ms 348 KB Output is correct
8 Correct 5 ms 556 KB Output is correct
9 Correct 5 ms 348 KB Output is correct
10 Correct 5 ms 348 KB Output is correct
11 Correct 5 ms 348 KB Output is correct
12 Correct 5 ms 564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3544 ms 1540 KB Output is correct
2 Correct 2213 ms 2744 KB Output is correct
3 Correct 3552 ms 2900 KB Output is correct
4 Execution timed out 5046 ms 3540 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 116 ms 520 KB Output is correct
2 Correct 274 ms 860 KB Output is correct
3 Correct 435 ms 1208 KB Output is correct
4 Correct 956 ms 1908 KB Output is correct
5 Correct 3948 ms 2544 KB Output is correct
6 Correct 3924 ms 2676 KB Output is correct
7 Correct 3989 ms 2780 KB Output is correct
8 Correct 3956 ms 2932 KB Output is correct
9 Execution timed out 5057 ms 1988 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1423 ms 1180 KB Output is correct
2 Correct 1666 ms 2548 KB Output is correct
3 Correct 896 ms 2104 KB Output is correct
4 Correct 1235 ms 2652 KB Output is correct
5 Correct 3979 ms 3940 KB Output is correct
6 Correct 3982 ms 3804 KB Output is correct
7 Correct 4005 ms 3796 KB Output is correct
8 Correct 3925 ms 4072 KB Output is correct
9 Execution timed out 5042 ms 2792 KB Time limit exceeded
10 Halted 0 ms 0 KB -