結果
問題 |
No.1594 Three Classes
|
ユーザー |
|
提出日時 | 2021-10-31 17:34:36 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 88 ms / 2,000 ms |
コード長 | 455 bytes |
コンパイル時間 | 106 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 12,288 KB |
最終ジャッジ日時 | 2024-11-16 08:33:24 |
合計ジャッジ時間 | 2,565 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
コンパイルメッセージ
Syntax OK
ソースコード
$N = gets.to_i $e = gets.split(" ").map{|s| s.to_i} def search(a, b, c, i) return true if i == $N v = $e[i] if a + v <= $target then return true if search(a+v, b, c, i+1) end if b + v <= $target then return true if search(a, b+v, c, i+1) end if c + v <= $target then return true if search(a, b, c+v, i+1) end return false end sum = $e.sum if sum % 3 != 0 then puts "No" else $target = sum / 3 puts search(0, 0, 0, 0) ? "Yes" : "No" end