Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.cpp
- // 11659-01
- //
- // Created by dhpark on 4/28/17.
- // Copyright © 2017 dhpark. All rights reserved.
- //
- // 구간 합 구하기 4
- #include <cstdio>
- const int MAX_N = 100000 ;
- int N, M, S[MAX_N+1], I, J ;
- int main(int argc, const char * argv[]) {
- scanf("%d %d", &N, &M);
- for(int i=1 ; i<=N ; i++){
- scanf("%d", &S[i]);
- S[i] += S[i-1] ;
- }
- while (M--) {
- scanf("%d %d", &I, &J);
- printf("%d\n", S[J]-S[I-1]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement