From 7e261a42d8091119c5f259a63342c4b9f7da107c Mon Sep 17 00:00:00 2001 From: songyc macbook Date: Tue, 11 Nov 2025 20:12:20 +0900 Subject: [PATCH] 20251111 baekjoon --- code_study/Baekjoon/ts/1806.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 code_study/Baekjoon/ts/1806.ts diff --git a/code_study/Baekjoon/ts/1806.ts b/code_study/Baekjoon/ts/1806.ts new file mode 100644 index 0000000..3b7989d --- /dev/null +++ b/code_study/Baekjoon/ts/1806.ts @@ -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); \ No newline at end of file