제출 #1181269

#제출 시각아이디문제언어결과실행 시간메모리
1181269vneduSterilizing Spray (JOI15_sterilizing)C++20
0 / 100
14 ms1600 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

template<class T> bool maximize(T &a, const T &b){ return (a < b ? a = b, 1 : 0); }
template<class T> bool minimize(T &a, const T &b){ return (a > b ? a = b, 1 : 0); }

#define fi first
#define se second

#define pb push_back
#define ii pair<int, int>

#define all(x) x.begin(), x.end()

#define TASK "nonsense"

/// end of template ///

const int N = 1e5 + 15;
const int Q = 1e5 + 15;

struct Query
{
    int s,t,u;
    Query() {}
    void input()
    {
        cin>>s>>t>>u;
    }
} query[Q];

int n,q,a[N],k;
namespace sub1
{
    bool check()
    {
        return max(n,q)<=3000;
    }
    void solve()
    {
        for (int i=1; i<=q; ++i)
        {
            if (query[i].s==1) a[query[i].t]=query[i].u;
            else if (query[i].s==2)
            {
                for (int i=query[i].t; i<=query[i].u; ++i)
                {
                    a[i]/=k;
                }
            }
            else
            {
                ll ans=0;
                for (int i=query[i].t; i<=query[i].u; ++i)
                {
                    ans+=a[i];
                }
                cout<<ans<<'\n';
            }
        }
    }
}
void solve()
{
    cin>>n>>q>>k;
    for (int i=1; i<=n; ++i) cin>>a[i];
    for (int i=1; i<=q; ++i) query[i].input();
    if (sub1::check()) return void(sub1::solve());
}

int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

//    freopen(TASK".inp","r",stdin);
//    freopen(TASK".out","w",stdout);

    int testcase=1;
//    cin>>testcase;

    while (testcase--)
        solve();

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...