Skip to content

Commit 9efbb19

Browse files
authored
Create 1646-staticRangeSumQueries.cpp
1 parent 9eeaedb commit 9efbb19

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// JAI BAJARANG BALI
2+
3+
// manitianajay45
4+
5+
// give me some sunshine, give me some rain ,give me another chance to grow up once again....
6+
7+
// sab moh maya hai....
8+
9+
#include <bits/stdc++.h>
10+
using namespace std;
11+
12+
#define ll long long
13+
14+
int main()
15+
{
16+
17+
ios_base::sync_with_stdio(false);
18+
cin.tie(NULL);
19+
ll n,q;
20+
cin>>n>>q;
21+
ll arr[n+1];
22+
arr[0]=0;
23+
for(ll i=1;i<=n;i++)
24+
{
25+
cin>>arr[i];
26+
arr[i]+=arr[i-1];
27+
}
28+
while(q--){
29+
ll l,r;
30+
cin>>l>>r;
31+
l--;
32+
ll ans=arr[r]-arr[l];
33+
cout<<ans<<endl;
34+
}
35+
return 0;
36+
}

0 commit comments

Comments
 (0)