diff --git "a/\354\241\260\353\257\274\354\230\201/1806 \353\266\200\353\266\204\355\225\251.java" "b/\354\241\260\353\257\274\354\230\201/1806 \353\266\200\353\266\204\355\225\251.java" new file mode 100644 index 0000000..5740ac7 --- /dev/null +++ "b/\354\241\260\353\257\274\354\230\201/1806 \353\266\200\353\266\204\355\225\251.java" @@ -0,0 +1,38 @@ +import java.io.*; +import java.util.*; + +public class g1806 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + StringTokenizer st = new StringTokenizer(br.readLine()); + + int n = Integer.parseInt(st.nextToken()); + int s = Integer.parseInt(st.nextToken()); + + int[] arr = new int[n]; + st = new StringTokenizer(br.readLine()); + + for ( int i = 0 ; i < n ; i++ ) + arr[i] = Integer.parseInt(st.nextToken()); + + int start = 0; + int end = 0; + int sum = 0; + int min = Integer.MAX_VALUE; + boolean exist = false; + + while ( true ) { + if ( sum >= s ) { + min = Math.min(min, end-start); + sum -= arr[start++]; + exist = true; + } else if ( end == n ) + break; + else + sum += arr[end++]; + } + + System.out.println(exist ? min : 0 ); + } +} \ No newline at end of file