Submission #69319921


Source Code Expand

function Main(inputText) {
    /** @type {String[][]} - スペース区切りと改行区切りをそのまま2次元配列に変えた状態 */
    const input = inputText.trim().split("\n").map(row => row.split(" "));
    /* ==== 本体 ==== */
    const CLOSED = 1;
    const OPENED = 0;
    const [N, R] = input[0].map(n => +n);
    const L = [, ...input[1].map(n => +n)]; // <- 左端に0があったところで答え変わらん
    // 左右端それぞれ、閉じたドアは何連続?
    const left_side_closed_count = L.findIndex(el => el === OPENED) - 1;
    const right_side_closed_count = L.length - L.findLastIndex(el => el === OPENED);
    // `閉じてるやつ全部開けてから全部閉じる`をするとき
    const count_closed = L.filter(n => n === CLOSED).length;
    const upper = count_closed + N;
    // (左|右)端までいかなくてもいい (自分より(左|右)の端が全て閉じたドアの場合)
    const left_ignore_able_count = Math.min(R, left_side_closed_count);
    const right_ignore_able_count = Math.min(N - R, right_side_closed_count);
    console.log(upper - (left_ignore_able_count + right_ignore_able_count) * 2);
    console.log(upper, left_ignore_able_count, right_ignore_able_count);
}
/* ==== これを書かないといけないらしい ==== */
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Submission Info

Submission Time
Task C - Lock All Doors
User AXT_AyaKoto
Language JavaScript (Node.js 18.16.1)
Score 0
Code Size 1389 Byte
Status WA
Exec Time 84 ms
Memory 62012 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
WA × 3
WA × 33
Set Name Test Cases
Sample sample00.txt, sample01.txt, sample02.txt
All sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt, testcase28.txt, testcase29.txt
Case Name Status Exec Time Memory
sample00.txt WA 44 ms 42708 KiB
sample01.txt WA 42 ms 42752 KiB
sample02.txt WA 42 ms 42588 KiB
testcase00.txt WA 84 ms 55972 KiB
testcase01.txt WA 70 ms 59708 KiB
testcase02.txt WA 64 ms 55128 KiB
testcase03.txt WA 68 ms 59596 KiB
testcase04.txt WA 48 ms 46016 KiB
testcase05.txt WA 72 ms 61556 KiB
testcase06.txt WA 67 ms 57836 KiB
testcase07.txt WA 76 ms 61460 KiB
testcase08.txt WA 56 ms 50660 KiB
testcase09.txt WA 70 ms 60028 KiB
testcase10.txt WA 64 ms 55868 KiB
testcase11.txt WA 70 ms 60068 KiB
testcase12.txt WA 46 ms 44932 KiB
testcase13.txt WA 70 ms 60180 KiB
testcase14.txt WA 66 ms 57672 KiB
testcase15.txt WA 69 ms 60048 KiB
testcase16.txt WA 71 ms 61184 KiB
testcase17.txt WA 74 ms 61492 KiB
testcase18.txt WA 43 ms 43008 KiB
testcase19.txt WA 70 ms 60044 KiB
testcase20.txt WA 62 ms 53816 KiB
testcase21.txt WA 73 ms 62012 KiB
testcase22.txt WA 69 ms 60232 KiB
testcase23.txt WA 74 ms 61580 KiB
testcase24.txt WA 68 ms 57448 KiB
testcase25.txt WA 73 ms 61712 KiB
testcase26.txt WA 71 ms 60440 KiB
testcase27.txt WA 70 ms 60292 KiB
testcase28.txt WA 73 ms 61764 KiB
testcase29.txt WA 74 ms 61756 KiB