20251111 baekjoon

This commit is contained in:
songyc macbook 2025-11-11 20:12:20 +09:00
parent ad1722323a
commit 7e261a42d8

View File

@ -0,0 +1,19 @@
export {};
const input = require("fs").readFileSync(0).toString().trim().split('\n');
const [N, S] = input[0].split(" ").map(Number);
const nums = input[1].split(" ").map(Number);
let [L, R] = [0,0];
let minLength = 100001;
let acc = 0;
while(true) {
if(acc >= S) {
minLength = Math.min(minLength, R-L);
acc -= nums[L++];
}
else if(R === N) break;
else acc += nums[R++];
}
console.log(minLength === 100001 ? 0 : minLength);