Skip to content

Commit

Permalink
Merge pull request #32 from ashutosh-3474/mediumday6
Browse files Browse the repository at this point in the history
chore: solved medium day6 task
  • Loading branch information
opabhijeet authored Apr 4, 2024
2 parents daa2aff + d639535 commit 4b7c426
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 4b7c426

Please sign in to comment.