20251111 baekjoon
This commit is contained in:
parent
ad1722323a
commit
7e261a42d8
19
code_study/Baekjoon/ts/1806.ts
Normal file
19
code_study/Baekjoon/ts/1806.ts
Normal 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);
|
||||||
Loading…
x
Reference in New Issue
Block a user