Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 |
Tags
- 시뮬레이션
- 문자열
- db
- 자바
- 러닝일지
- 알고리즘
- Java
- 문제풀이
- BOJ
- DP
- BFS
- priorityqueue
- 투포인터
- MySQL
- 문제해결
- 운동기록
- 건강
- math
- binary search
- SWEA
- COS PRO
- 코딩테스트
- 프로그래머스
- 이분탐색
- oracle
- 백준
- greedy
- SQL
- 코테
- dfs
Archives
- Today
- Total
슈콩
[BOJ] 백준 11659 구간 합 구하기 4 본문

[문제]
https://www.acmicpc.net/problem/11659
[소스 코드]
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
int m = Integer.parseInt(st.nextToken());
int[] nums = new int[n+1];
st = new StringTokenizer(br.readLine());
for(int i=1;i<=n;i++) {
nums[i] = nums[i-1] + Integer.parseInt(st.nextToken());
}
for(int d=0;d<m;d++) {
st = new StringTokenizer(br.readLine());
int i = Integer.parseInt(st.nextToken());
int j = Integer.parseInt(st.nextToken());
System.out.println(nums[j]-nums[i-1]);
}
}
}'Algorithms > Baekjoon' 카테고리의 다른 글
| [BOJ] 백준 1799 비숍 (0) | 2025.11.26 |
|---|---|
| [BOJ] 백준 11600 구간 합 구하기 5 (0) | 2025.11.12 |
| [BOJ] 백준 2003 수들의 합 2 (0) | 2025.11.11 |
| [BOJ] 백준 21921 블로그 (0) | 2025.11.11 |
| [BOJ] 백준 3151 합이 0 (0) | 2025.10.06 |