結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-05-14 16:58:14 |
| 言語 | Ruby (3.4.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 446 bytes |
| コンパイル時間 | 42 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 19,616 KB |
| 最終ジャッジ日時 | 2024-09-16 05:50:48 |
| 合計ジャッジ時間 | 7,763 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 TLE * 1 -- * 7 |
コンパイルメッセージ
Syntax OK
ソースコード
def f(a, total)
r = []
g = lambda{|res, idx|
return false if res > total
return res == total if idx == a.size
[:+, :*].each{|op|
new_res = res.send(op, a[idx])
next if new_res > total
r << op
if g.(new_res, idx+1)
return true
end
r.pop
}
false
}
first = a.shift
g.(first, 0)
r
end
N = gets.to_i
Total = gets.to_i
A = gets.split.take(N).map(&:to_i)
puts f(A, Total)*""