結果
| 問題 |
No.110 しましまピラミッド
|
| コンテスト | |
| ユーザー |
d_nishiyama85
|
| 提出日時 | 2016-07-11 00:09:07 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 445 bytes |
| コンパイル時間 | 50 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 12,288 KB |
| 最終ジャッジ日時 | 2024-10-13 10:33:41 |
| 合計ジャッジ時間 | 3,858 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 25 WA * 1 |
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - nw Main.rb:3: warning: assigned but unused variable - nb Syntax OK
ソースコード
nw = gets.to_i
ws = gets.strip.split.map(&:to_i)
nb = gets.to_i
bs = gets.strip.split.map(&:to_i)
ws.sort!
ws.reverse!
bs.sort!
bs.reverse!
def search(ws, bs)
h = 0
while !ws.empty? || !ws.empty?
w = ws.shift
h += 1
bs = bs.select { |b| b < w }
if bs.empty?
break
else
b = bs.shift
h += 1
ws = ws.select { |w| w < b }
end
end
return h
end
puts [search(ws, bs), search(bs, ws)].max()
d_nishiyama85