結果

問題 No.1564 Sum of Products of Pairs
コンテスト
ユーザー irumo8202
提出日時 2022-02-17 22:41:08
言語 TypeScript
(6.0.2)
コンパイル:
tsc.sh -p tsconfig.json
実行:
node main.js ONLINE_JUDGE
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 512 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,721 ms
コンパイル使用メモリ 346,892 KB
最終ジャッジ日時 2026-06-05 06:04:42
合計ジャッジ時間 5,474 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.ts(5,24): error TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
  Type 'undefined' is not assignable to type 'string'.
main.ts(6,15): error TS2532: Object is possibly 'undefined'.

ソースコード

diff #
raw source code

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