結果

問題 No.1564 Sum of Products of Pairs
ユーザー irumo8202
提出日時 2022-02-17 22:41:08
言語 TypeScript
(5.7.2)
結果
AC  
実行時間 368 ms / 2,000 ms
コード長 512 bytes
コンパイル時間 8,383 ms
コンパイル使用メモリ 228,812 KB
実行使用メモリ 65,612 KB
最終ジャッジ日時 2024-12-31 16:46:28
合計ジャッジ時間 16,057 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import * as fs from "fs"

const main = (args: string): void => {
    const input = args.trim().split("\n");
    const N = parseInt(input.shift())
    const A = input.shift().split(" ").map(x => Number(x))
    A.sort((x, y) => x > y ? -1 : 1)
    let ans = BigInt(0)

    for (let i = 0; i < 2 * N; i += 2) {
        ans += BigInt(A[i] * A[i + 1])
    }
    console.log(String(ans))
}

main(fs.readFileSync('/dev/stdin', 'utf8'));

function apply<T, R>(value: T, func: (arg: T) => R): R {
    return func(value)
}
0