시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
3 초 128 MB 652 85 66 18.966%

문제

길이가 N인 정수 수열과 정수 X가 주어진다. 이때, 합이 X보다 크거나 같은 연속 부분 수열 중에서 길이가 가장 짧은 것을 찾는 프로그램을 작성하시오.

입력

첫째 줄에 테스트 케이스의 개수 T가 주어진다. 각 테스트 케이스의 첫째 줄에는 N (1 ≤ N ≤ 500,000)과 X (-109 ≤ X ≤ 109)가 주어진다. 둘째 줄에는 수열에 들어있는 정수 N개가 주어진다. 이 정수는 -109보다 크거나 같고, 109보다 작거나 같다.

출력

각 테스트 케이스마다 합이 X보다 크거나 같은 연속 부분 수열 중 가장 짧은 길이를 출력한다. 만약, 그러한 배열이 없는 경우에는 -1을 출력한다.

예제 입력 1

3
5 4
1 2 1 2 1
6 -2
-5 -6 -7 -8 -9 -10
5 3
-1 1 1 1 -1

예제 출력 1

3
-1
3
W3sicHJvYmxlbV9pZCI6Ijk2MjMiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWJkODBcdWJkODQgXHVjMjE4XHVjNWY0XHVjNzU4IFx1YWUzOFx1Yzc3NCIsImRlc2NyaXB0aW9uIjoiPHA+XHVhZTM4XHVjNzc0XHVhYzAwIE5cdWM3NzggXHVjODE1XHVjMjE4IFx1YzIxOFx1YzVmNFx1YWNmYyBcdWM4MTVcdWMyMTggWFx1YWMwMCBcdWM4ZmNcdWM1YjRcdWM5YzRcdWIyZTQuIFx1Yzc3NFx1YjU0YywgXHVkNTY5XHVjNzc0IFhcdWJjZjRcdWIyZTQgXHVkMDZjXHVhYzcwXHViMDk4IFx1YWMxOVx1Yzc0MCBcdWM1ZjBcdWMxOGQgXHViZDgwXHViZDg0IFx1YzIxOFx1YzVmNCBcdWM5MTFcdWM1ZDBcdWMxMWMgXHVhZTM4XHVjNzc0XHVhYzAwIFx1YWMwMFx1YzdhNSBcdWM5ZTdcdWM3NDAgXHVhYzgzXHVjNzQ0IFx1Y2MzZVx1YjI5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