結果

問題 No.102 トランプを奪え
ユーザー maimai
提出日時 2017-05-19 08:09:33
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 614 bytes
コンパイル時間 432 ms
コンパイル使用メモリ 11,836 KB
実行使用メモリ 16,156 KB
最終ジャッジ日時 2023-10-19 02:35:15
合計ジャッジ時間 2,622 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
16,052 KB
testcase_01 AC 91 ms
16,052 KB
testcase_02 AC 88 ms
16,052 KB
testcase_03 AC 89 ms
16,052 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 92 ms
16,052 KB
testcase_07 WA -
testcase_08 AC 89 ms
16,052 KB
testcase_09 AC 88 ms
16,052 KB
testcase_10 AC 89 ms
16,052 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def scan; gets.split.map(&:to_i); end

@dp={}
def guchoku216(aa,turn=true)
    return !turn if aa.size == 0
    
    aa.sort!
    return @dp[aa+[turn]] if @dp[aa+[turn]]
    
    aa.each_index{|i|
        ac = aa.clone
        ac[i]-=1
        3.times{
            break if ac[i] <= 0
            return @dp[aa+[turn]] = turn if (guchoku216(ac.clone,!turn) == turn)
            ac[i]-=1
        }
        ac.delete(0)
        return @dp[aa+[turn]] = turn if (guchoku216(ac.clone,!turn) == turn)
    }
    return @dp[aa+[turn]] = !turn
end

nn = scan.map{|e|e%6}
nn.delete(0)

puts guchoku216(nn) ? "Taro" : "Jiro"
0