Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. //
  2. // main.cpp
  3. // 11659-01
  4. //
  5. // Created by dhpark on 4/28/17.
  6. // Copyright © 2017 dhpark. All rights reserved.
  7. //
  8. // 구간 합 구하기 4
  9.  
  10. #include <cstdio>
  11. const int MAX_N = 100000 ;
  12. int N, M, S[MAX_N+1], I, J ;
  13. int main(int argc, const char * argv[]) {
  14. scanf("%d %d", &N, &M);
  15. for(int i=1 ; i<=N ; i++){
  16. scanf("%d", &S[i]);
  17. S[i] += S[i-1] ;
  18. }
  19. while (M--) {
  20. scanf("%d %d", &I, &J);
  21. printf("%d\n", S[J]-S[I-1]);
  22. }
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement