File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
src/main/java/main/java/videos Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change
1
+ package main .java .videos ;
2
+
3
+ import java .io .BufferedReader ;
4
+ import java .io .IOException ;
5
+ import java .io .InputStreamReader ;
6
+
7
+ public class SingleUseStones {
8
+ public static void main (final String args []) throws IOException {
9
+ final BufferedReader bufferedReader = new BufferedReader (new InputStreamReader (System .in ));
10
+ String line [] = bufferedReader .readLine ().split (" " );
11
+ final int w = Integer .parseInt (line [0 ]), l = Integer .parseInt (line [1 ]);
12
+ line = bufferedReader .readLine ().split (" " );
13
+ final int a [] = new int [line .length ];
14
+ for (int i = 0 ; i < a .length ; i ++) {
15
+ a [i ] = Integer .parseInt (line [i ]);
16
+ }
17
+ int sum = 0 ;
18
+ for (int i = 0 ; i < l ; i ++) {
19
+ sum += a [i ];
20
+ }
21
+ int minValue = sum ;
22
+ for (int i = l ; i < w - 1 ; i ++) {
23
+ sum = sum - a [i - l ] + a [i ];
24
+ minValue = Math .min (minValue , sum );
25
+ }
26
+ System .out .println (minValue );
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments