Falak_Ahmed_Shakib

comilitive

May 30th, 2020 (edited)
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. typedef pair<ll,ll> pll;
  5. #define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL))
  6. #define fi first
  7. #define se second
  8. #define pb push_back
  9. #define eb emplace_back
  10. ll const MOD=1000000007;
  11. const int M= 2e5 + 10;
  12. ll cost[M+10];
  13. vector<ll>v[M+1];
  14. ll n,m,a,b;
  15. int main()
  16. {
  17. fastread();
  18.  
  19. ll n,q;
  20.  
  21. cin>>n>>q;
  22.  
  23.  
  24.  
  25. ll ara[n+1];
  26.  
  27.  
  28. for(ll i=1;i<=n;i++)cin>>ara[i];
  29.  
  30. ara[0]=0;
  31.  
  32. for(ll i=1;i<=n;i++)
  33. {
  34. ara[i]+=ara[i-1];
  35. }
  36.  
  37. while(q--)
  38. {
  39. ll l ,r;
  40.  
  41. cin>>l>>r;
  42.  
  43. ll sum=ara[r]-ara[l-1];
  44.  
  45.  
  46. cout<<sum<<endl;
  47.  
  48.  
  49.  
  50.  
  51. }
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59. }
  60.  
  61.  
Add Comment
Please, Sign In to add comment