提出 #65654250


ソースコード 拡げる

function Main(inputText) {
    /** @type {String[][]} - スペース区切りと改行区切りをそのまま2次元配列に変えた状態 */
    const input = inputText.trim().split("\n").map(row => row.split(" "));
    /* ==== 本体 ==== */
    const N = +input[0][0];
    const A = input[1].map(n => BigInt(n));
    // 後ろからの累積和をつくる
    const A_acc = [];
    let sum = 0n;
    for (let i = A.length - 1; i >= 0; i--) {
        sum += A[i];
        A_acc[i] = sum;
    }
    // 最後以外の各要素について、「それ自体 × それ以降の要素の総和」を求めて足す
    let factorization = 0n;
    for (let i = 0; i < A.length - 1; i++) {
        factorization += A[i] * A_acc[i + 1];
    }
    console.log(factorization.toString());
}
/* ==== これを書かないといけないらしい ==== */
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

提出情報

提出日時
問題 C - Sum of Product
ユーザ AXT_AyaKoto
言語 JavaScript (Node.js 18.16.1)
得点 300
コード長 925 Byte
結果 AC
実行時間 286 ms
メモリ 115180 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 22
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 02_handmade_00.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 39 ms 42808 KiB
00_sample_01.txt AC 39 ms 42732 KiB
00_sample_02.txt AC 39 ms 42736 KiB
01_random_00.txt AC 286 ms 72216 KiB
01_random_01.txt AC 154 ms 95036 KiB
01_random_02.txt AC 182 ms 112436 KiB
01_random_03.txt AC 115 ms 80508 KiB
01_random_04.txt AC 154 ms 95348 KiB
01_random_05.txt AC 189 ms 113064 KiB
01_random_06.txt AC 191 ms 115180 KiB
01_random_07.txt AC 190 ms 111376 KiB
01_random_08.txt AC 191 ms 111984 KiB
01_random_09.txt AC 190 ms 112696 KiB
01_random_10.txt AC 190 ms 114072 KiB
01_random_11.txt AC 190 ms 113136 KiB
01_random_12.txt AC 191 ms 112720 KiB
01_random_13.txt AC 190 ms 112696 KiB
01_random_14.txt AC 191 ms 112740 KiB
02_handmade_00.txt AC 39 ms 42888 KiB
02_handmade_01.txt AC 39 ms 42820 KiB
02_handmade_02.txt AC 159 ms 91740 KiB
02_handmade_03.txt AC 190 ms 113872 KiB