-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path수열.java
More file actions
25 lines (20 loc) · 774 Bytes
/
수열.java
File metadata and controls
25 lines (20 loc) · 774 Bytes
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
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int n, m, ans;
int[] sum;
n = Integer.parseInt(st.nextToken());
m = Integer.parseInt(st.nextToken());
ans = -10000000;
sum = new int[n + 1];
st = new StringTokenizer(br.readLine());
for(int i = 1; i < n + 1; i++) sum[i] = sum[i - 1] + Integer.parseInt(st.nextToken());
for(int i = m; i < n + 1; i++){
ans = Math.max(ans, sum[i] - sum[i - m]);
}
System.out.println(ans);
}
}