#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)
{
if(k==1)
continue;
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;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
7 ms |
340 KB |
Output is correct |
4 |
Correct |
47 ms |
416 KB |
Output is correct |
5 |
Correct |
109 ms |
440 KB |
Output is correct |
6 |
Correct |
114 ms |
440 KB |
Output is correct |
7 |
Correct |
105 ms |
452 KB |
Output is correct |
8 |
Correct |
105 ms |
456 KB |
Output is correct |
9 |
Correct |
111 ms |
452 KB |
Output is correct |
10 |
Correct |
117 ms |
448 KB |
Output is correct |
11 |
Correct |
108 ms |
444 KB |
Output is correct |
12 |
Correct |
119 ms |
444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
54 ms |
3156 KB |
Output is correct |
2 |
Correct |
45 ms |
3172 KB |
Output is correct |
3 |
Correct |
47 ms |
4256 KB |
Output is correct |
4 |
Correct |
69 ms |
5272 KB |
Output is correct |
5 |
Correct |
71 ms |
5700 KB |
Output is correct |
6 |
Correct |
70 ms |
5712 KB |
Output is correct |
7 |
Correct |
74 ms |
5664 KB |
Output is correct |
8 |
Correct |
68 ms |
5640 KB |
Output is correct |
9 |
Correct |
66 ms |
5516 KB |
Output is correct |
10 |
Correct |
65 ms |
5592 KB |
Output is correct |
11 |
Correct |
65 ms |
5600 KB |
Output is correct |
12 |
Correct |
73 ms |
5568 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3692 ms |
656 KB |
Output is correct |
2 |
Execution timed out |
5017 ms |
1464 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5066 ms |
1772 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |