結果
| 問題 |
No.110 しましまピラミッド
|
| コンテスト | |
| ユーザー |
horiesiniti
|
| 提出日時 | 2018-03-16 09:17:48 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 90 ms / 5,000 ms |
| コード長 | 571 bytes |
| コンパイル時間 | 77 ms |
| コンパイル使用メモリ | 7,680 KB |
| 実行使用メモリ | 12,416 KB |
| 最終ジャッジ日時 | 2024-12-31 11:38:08 |
| 合計ジャッジ時間 | 3,790 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
コンパイルメッセージ
Syntax OK
ソースコード
def f(h,c,b,w,ans)
if b.empty? ==true && c.empty? ==true
return ans
end
if (c=="w" && b.empty? ==true) || (c=="b" && w.empty? ==true)
return ans
end
res=0
if c=="w"
e=b.pop
if e<h
res=f(e,"b",b,w,ans+1)
else
res= f(h,"w",b,w,ans)
end
b.push(e)
else
e=w.pop
if e<h
res= f(e,"w",b,w,ans+1)
else
res= f(h,"b",b,w,ans)
end
w.push(e)
end
return res
end
gets
b=gets.split.map{|e| e.to_i}.sort
gets
w=gets.split.map{|e| e.to_i}.sort
e=b.pop
ans0=f(e,"b",b,w,1)
b.push(e)
e=w.pop
ans1=f(e,"w",b,w,1)
w.push(e)
puts [ans0,ans1].max
horiesiniti