# BOJ02559 수열
https://www.acmicpc.net/problem/2559 (opens new window)
매일 아침 9시에 학교에서 측정한 온도가 어떤 정수의 수열로 주어졌을 때, 연속적인 며칠 동안의 온도의 합이 가장 큰 값을 알아보고자 한다.
# 누적합
누적합 (Prefix Sum, Cumulative Sum) (opens new window)
# 제출 코드
import java.util.Scanner;
public class BOJ02559 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt(); // 온도를 측정한 전체 날짜의 수
int k = scanner.nextInt(); // k는 합을 구하기 위한 연속적인 날짜의 수
int[] temperatures = new int[n + 1];
for (int i = 1; i <= n; i++) {
temperatures[i] = temperatures[i - 1] + scanner.nextInt();
}
int max = Integer.MIN_VALUE;
for (int i = k; i <= n; i++) {
max = Math.max(max, temperatures[i] - temperatures[i - k]);
}
System.out.println(max);
}
}
# 두 포인터
// TODO