結果

問題 No.723 2つの数の和
ユーザー Tksi
提出日時 2019-03-06 13:26:16
言語 JavaScript
(node v23.5.0)
結果
WA  
実行時間 -
コード長 372 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 6,692 KB
実行使用メモリ 60,404 KB
最終ジャッジ日時 2024-10-13 01:00:59
合計ジャッジ時間 3,945 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other TLE * 1 -- * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

const input =   require('fs').readFileSync('/dev/stdin', 'utf8').slice(0,-1);
const [N, X, ...a] = input.split(/\s/);
const Counter = arr => [...new Set(arr)]
  .map(v1 => ([v1, arr.filter(v2 => v2 === v1).length]))
  .reduce((obj, [k, v]) => ({
    ...obj,
  [k]: v
  }), {});

const cnt = Counter(a);
console.log(
  a
  .map(v => cnt[X - v])
  .reduce((a, b) => a + b)
)
0