-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathaloo.java
More file actions
47 lines (33 loc) · 1022 Bytes
/
aloo.java
File metadata and controls
47 lines (33 loc) · 1022 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class aloo {
public static void alo() throws IOException
{ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String input = reader.readLine();
String[] ints = input.split(" ");
int int1 ,int2,max=0;
int1 = Integer.parseInt(ints[0]);
int2 = Integer.parseInt(ints[1]);
int[] cases = new int[int1];
int j=0;
while ( j < int1){
cases[j] = Integer.parseInt(reader.readLine());
j=j+1;}
int k = int2;
while (k <= int1){
int l =0;
while (l<int1-k+1)
{
int sum = 0;
for (int a = 0; a<k;a++){
sum = sum + cases[l+a];}
if (sum>max){max = sum;}
l=l+1; }
k=k+1;}
System.out.println(max);
}
public static void main(String[] args) throws IOException{
alo();
}
}