結果
| 問題 |
No.437 cwwゲーム
|
| コンテスト | |
| ユーザー |
suppy193
|
| 提出日時 | 2016-11-02 13:24:15 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 137 ms / 2,000 ms |
| コード長 | 686 bytes |
| コンパイル時間 | 40 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 12,416 KB |
| 最終ジャッジ日時 | 2024-10-12 08:35:53 |
| 合計ジャッジ時間 | 5,432 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
コンパイルメッセージ
Main.rb:3: warning: assigned but unused variable - score Syntax OK
ソースコード
a = gets.strip.split('').map(&:to_i)
#p a
score = 0
@max_score = 0
def dfs(a, score)
(0...a.length).to_a.combination(3) do |set|
#p set
#p a
subscore = 0
if a[set[0]] != a[set[1]] && a[set[1]] == a[set[2]] && a[set[0]] != 0
#print "#{a[set[0]]}#{a[set[1]]}#{a[set[2]]}\n"
subscore = (a[set[0]].to_s + a[set[1]].to_s + a[set[2]].to_s).to_i
#p score + subscore
if score + subscore > @max_score
@max_score = score + subscore
end
next_a = a.clone
#p set
set.each do |index|
#p next_a
#print "index #{index}\n"
next_a[index] = nil
end
next_a.compact!
#p next_a
dfs(next_a, score + subscore)
end
end
end
dfs(a, 0)
p @max_score
suppy193