Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef pair<ll,ll> pll;
- #define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL))
- #define fi first
- #define se second
- #define pb push_back
- #define eb emplace_back
- ll const MOD=1000000007;
- const int M= 2e5 + 10;
- ll cost[M+10];
- vector<ll>v[M+1];
- ll n,m,a,b;
- int main()
- {
- fastread();
- ll n,q;
- cin>>n>>q;
- ll ara[n+1];
- for(ll i=1;i<=n;i++)cin>>ara[i];
- ara[0]=0;
- for(ll i=1;i<=n;i++)
- {
- ara[i]+=ara[i-1];
- }
- while(q--)
- {
- ll l ,r;
- cin>>l>>r;
- ll sum=ara[r]-ara[l-1];
- cout<<sum<<endl;
- }
- }
Add Comment
Please, Sign In to add comment