Submission #750104

# Submission time Handle Problem Language Result Execution time Memory
750104 2023-05-29T06:49:11 Z Yazan_SA Sterilizing Spray (JOI15_sterilizing) C++17
5 / 100
5000 ms 2452 KB
#include<bits/stdc++.h>
#include <cstdio>
#define endl "\n"
/*/*(last choice)*/ #define int long long
#define all(x) x.begin(), x.end()
#define ll long long
#define tsts int t; cin>>t; while(t--)
#define start cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
int tree[10000005];
void update(int l, int r, int idx, int val, int node=1)
{
    if(l>idx || r<idx)
        return;
    if(l==r)
    {
        tree[node]=val;
        return;
    }
    int mid=(l+r)/2;
    update(l,mid,idx,val,node*2);
    update(mid+1,r,idx,val,node*2+1);
    tree[node]=tree[node*2]+tree[node*2+1];
}
int gett(int l, int r, int ul, int ur, int node=1)
{
    if(l>ur || r<ul)
        return 0;
    if(l>=ul && r<=ur)
        return tree[node];
    int mid=(l+r)/2;
    return (gett(l,mid,ul,ur,node*2) + gett(mid+1,r,ul,ur,node*2+1));
}
signed main()
{
    start
    //freopen("codeblocksinput.txt", "w", stdout);
    int n,q,k;
    cin>>n>>q>>k;
    vector<int>v(n);
    for(int i=0; i<n; i++)
    {
        cin>>v[i];
        update(0,1e6,i,v[i]);
    }
    while(q--)
    {
        int x, l ,r;
        cin>>x>>l>>r;
        if(x==1)
        {
            v[l-1]=r;
            update(0,1e6,l-1,r);
        }
        else if(x==2)
        {
            for(int i=l-1 ;i<=r-1; i++)
                update(0,1e6,i,v[i]/k),v[i]/=k;
        }
        else
        {
            cout<<gett(0,1e6,l-1,r-1)<<endl;
        }
    }
}

# Verdict Execution time Memory Grader output
1 Correct 5 ms 340 KB Output is correct
2 Correct 12 ms 340 KB Output is correct
3 Correct 7 ms 468 KB Output is correct
4 Correct 48 ms 484 KB Output is correct
5 Correct 107 ms 508 KB Output is correct
6 Correct 115 ms 520 KB Output is correct
7 Correct 106 ms 524 KB Output is correct
8 Correct 106 ms 504 KB Output is correct
9 Correct 117 ms 512 KB Output is correct
10 Correct 125 ms 468 KB Output is correct
11 Correct 112 ms 512 KB Output is correct
12 Correct 116 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5054 ms 2452 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3191 ms 1116 KB Output is correct
2 Execution timed out 5047 ms 1776 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5036 ms 2400 KB Time limit exceeded
2 Halted 0 ms 0 KB -