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
- ์ฐ์ ์์ ํ
- c++
- ์คํ
- DP
- Spring
- ๊ตฌํ
- ๋ถํ ์ ๋ณต
- web
- ๋์ ํฉ
- error
- CVE
- ์ต๋จ ๊ฒฝ๋ก
- java
- ์์ ์ ๋ ฌ
- JPA
- BFS
- dfs
- ๋ฐ์ดํฌ์คํธ๋ผ
- OS
- ๋ฐฑํธ๋ํน
- ๋ฌธ์์ด
- thymeleaf
- ์๋ฎฌ๋ ์ด์
- ๊ทธ๋ฆฌ๋
- GCP
- ์ด๋ถ ํ์
- Reversing
- ์ฌ๊ท
- ๋งต
- dynamic debugging
Archives
- Today
- Total
hades
[Baekjoon] 11659๋ฒ: ๊ตฌ๊ฐ ํฉ ๊ตฌํ๊ธฐ ๋ณธ๋ฌธ
๐ฅ ๋ฌธ์
https://www.acmicpc.net/problem/11659
๐ ์ค๊ณ
i๋ฒ์งธ๋ถํฐ j๋ฒ์งธ๊น์ง์ ํฉ์ j๋ฒ์งธ๊น์ง์ ๋์ ํฉ์์ i-1๋ฒ์งธ๊น์ง์ ๋์ ํฉ์ ๋นผ๋ฉด ๋๋ค.
์ฃผ์ํ ๊ฒ์ ๋ฐฐ์ด์ 0๋ถํฐ ์์ํ์ง๋ง, ์ ๋ ฅ์ผ๋ก ๋ค์ด์ค๋ ๊ฒ์ ๋ช ๋ฒ์งธ์ ๋ํ ์ ๋ณด์ด๋ฏ๋ก 1๋ถํฐ ์์ํ๋ค.
๐ ํ์ด
package hades.ps;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n, m;
n = sc.nextInt();
m = sc.nextInt();
int[] arr = new int [n+1];
for (int k=1; k<=n; k++){
arr[k] = sc.nextInt();
}
int[] sum = new int [n+1];
for (int k=1; k<=n; k++){
sum[k] = sum[k-1] + arr[k];
}
int i, j;
for (int k=0; k<m; k++){
i = sc.nextInt();
j = sc.nextInt();
System.out.println(sum[j] - sum[i-1]);
}
}
}
'๐ PS > Algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Baekjoon] 11726๋ฒ: 2xn ํ์ผ๋ง (0) | 2024.07.26 |
---|---|
[Baekjoon] 11724๋ฒ: ์ฐ๊ฒฐ ์์์ ๊ฐ์ (0) | 2024.07.25 |
[Baekjoon] 11403๋ฒ: ๊ฒฝ๋ก ์ฐพ๊ธฐ (0) | 2024.07.25 |
[Baekjoon] 11399๋ฒ: ATM (0) | 2024.07.24 |
[Baekjoon] 11286๋ฒ: ์ ๋๊ฐ ํ (1) | 2024.07.23 |