Advertisement
Saleh127

CSES 1646

Apr 17th, 2021
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10. ll n,m,i,j,k,l;
  11.  
  12. cin>>n>>m;
  13.  
  14. ll a[n+5];
  15.  
  16. a[0]=0;
  17. cin>>a[1];
  18.  
  19. for(i=2;i<=n;i++)
  20. {
  21. cin>>a[i];
  22. a[i]+=a[i-1];
  23. }
  24. while(m--)
  25. {
  26. cin>>k>>l;
  27.  
  28. cout<<a[l]-a[k-1]<<endl;
  29. }
  30. return 0;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement