結果

問題 No.4 おもりと天秤
ユーザー gemmaro
提出日時 2020-07-30 08:33:43
言語 Ruby
(3.4.1)
結果
TLE  
実行時間 -
コード長 310 bytes
コンパイル時間 57 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 17,920 KB
最終ジャッジ日時 2024-07-03 02:59:26
合計ジャッジ時間 7,277 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 TLE * 1 -- * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# frozen_string_literal: true

def solve
  if W.sum.even? && W.balancable?
    'possible'
  else
    'impossible'
  end
end

class Array
  def balancable?
    (1..size / 2).any? do |left|
      combination(left).any? { 2 * _1.sum == sum }
    end
  end
end

N = gets.to_i
W = gets.split.map(&:to_i)

puts solve
0