EISHORT - Shortest subarray

Xem dạng PDF

Gửi bài giải

Điểm: 1,00 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 256M
Input: stdin
Output: stdout

Nguồn bài:
Hà Minh Ngọc
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

Given an array of positive integers ~A~ where each element has value at most ~10^6~. Find the shortest subarray of ~A~ such that the sum of elements is not less than ~k~.

Input

  • The first line contains the number of elements ~n~ and the integer ~k~ (~0 < n \leq 10^5~, ~0 < k \leq 10^9~).
  • The second line is the elements in array ~A~

Output

  • The length of the shortest subarray

Example Input 1

5 6
1 2 4 1 6

Example Output 1

1

Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.