結果

問題 No.4 おもりと天秤
ユーザー irisAsh
提出日時 2017-08-15 00:21:53
言語 JavaScript
(node v23.5.0)
結果
MLE  
実行時間 -
コード長 482 bytes
コンパイル時間 39 ms
コンパイル使用メモリ 6,692 KB
実行使用メモリ 573,052 KB
最終ジャッジ日時 2024-10-13 00:23:31
合計ジャッジ時間 9,152 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 MLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

let i = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')[1].split(' ').map((e) => parseInt(e))
let t = i.reduce((p,c) => p + c)
if (t % 2 == 1) console.log('impossible')
else {
  let r = []
  let h = t / 2
  let f = false
  for (let x of i) {
    let c = r.concat()
    c.push(x)
    r = r.map((e) => e+x)
    r = r.filter((e) => e <= h)
    r = r.concat(c)
    if (r.indexOf(h) > -1) {
      f = true
      break
    }
  }
  console.log(f ? 'possible' : 'impossible')
}
0