結果

問題 No.1686 Geschenkt
ユーザー testtest
提出日時 2022-11-22 07:04:30
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 421 bytes
コンパイル時間 198 ms
コンパイル使用メモリ 5,252 KB
実行使用メモリ 37,388 KB
最終ジャッジ日時 2023-10-24 00:11:20
合計ジャッジ時間 4,150 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
37,380 KB
testcase_01 AC 66 ms
37,380 KB
testcase_02 AC 66 ms
37,380 KB
testcase_03 AC 67 ms
37,380 KB
testcase_04 AC 66 ms
37,380 KB
testcase_05 AC 67 ms
37,388 KB
testcase_06 AC 66 ms
37,380 KB
testcase_07 AC 67 ms
37,380 KB
testcase_08 AC 67 ms
37,380 KB
testcase_09 AC 66 ms
37,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

function arrInt(arr) {
    return arr.map(str => parseInt(str, 10))
        .sort((a, b) => a - b);
}
function Main(input) {
    const src = input.split("\n");
    const n = parseInt(src[0]);
    const a = arrInt(src[1].split(" "));
    let ans = a[0];
    for (let i = 1; i < n; i++) {
        if (a[i - 1] != (a[i] - 1)) ans += a[i];
    }
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
0