Skip to content

Commit

Permalink
chore: solved medium day6 task
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutosh-3474 committed Apr 4, 2024
1 parent feb35d6 commit d639535
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions Medium/Day6/Solution.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,57 @@
// Write your code here
#include <bits/stdc++.h>
#include<atcoder/all>
using namespace std;
#define int long long int


/*---------------------------------------------------------------------------------*/



int op(int a, int b){return a + b;}
int e(){return 0;}

void solve ()
{

int n,q;
cin>>n>>q;
vector <int> a(n);
for (int i = 0; i < n; i++)
{
cin>>a[i];
}
atcoder::segtree<int, op, e> st(a);
for (int i = 0; i < q; i++)
{
int t;
cin>>t;
if (t==0){
int p,x;
cin>>p>>x;
st.set(p,st.get(p)+x);
}
else{
int l,r;
cin>>l>>r;
cout<<st.prod(l,r)<<endl;

}

}


}


signed main() {


solve();




}

0 comments on commit d639535

Please sign in to comment.