시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
3 초 128 MB 504 74 58 23.108%

문제

길이가 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+XHVhZTM4XHVjNzc0XHVhYzAwIE5cdWM3NzggXHVjODE1XHVjMjE4IFx1YzIxOFx1YzVmNFx1YWNmYyBcdWM4MTVcdWMyMTggWFx1YWMwMCBcdWM4ZmNcdWM1YjRcdWM5YzRcdWIyZTQuIFx1Yzc3NCBcdWI1NGMsIFx1ZDU2OVx1Yzc3NCBYXHViY2Y0XHViMmU0IFx1ZDA2Y1x1YWM3MFx1YjA5OCBcdWFjMTlcdWM3NDAgXHVjNWYwXHVjMThkIFx1YmQ4MFx1YmQ4NCBcdWMyMThcdWM1ZjQgXHVjOTExXHVjNWQwXHVjMTFjIFx1YWUzOFx1Yzc3NFx1YWMwMCBcdWFjMDBcdWM3YTUgXHVjOWU3XHVjNzQwIFx1YWM4M1x1Yzc0NCBcdWNjM2Vc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