結果
問題 |
No.459 C-VS for yukicoder
|
ユーザー |
|
提出日時 | 2016-12-04 01:30:05 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 320 ms / 2,000 ms |
コード長 | 1,185 bytes |
コンパイル時間 | 68 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 15,360 KB |
最終ジャッジ日時 | 2024-12-26 08:42:21 |
合計ジャッジ時間 | 10,092 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 58 |
コンパイルメッセージ
Syntax OK
ソースコード
# AC : パックを上下逆にする def max(a,b);a>=b ? a : b;end def min(a,b);a<=b ? a : b;end @height,@width,@n = gets.split.map(&:to_i) field = Array.new(@width,0) @height.times{ x = 0 gets.chomp!.chars{|c| field[x]+=1 if c=='#' x+=1 } } command = Array.new(@n,0) pack = Array.new(@n){Array.new(3,0)} command_bucket = Array.new(@width){[]} @n.times{|i| x = gets.to_i command[i] = x command_bucket[x] << i } cursor = 0 @width.times{|x| cursor = max(x,cursor) command_bucket[x].each{|idx| while (field[cursor] == 0) ; cursor += 1 ; end pack[idx][cursor-x] += 1 field[cursor] -= 1 } } @width.times{|x| command_bucket[x].each{|idx| 3.times{|ofs| fil = max(0,min(3-pack[idx][ofs],field[x+ofs])) pack[idx][ofs] += fil field[x+ofs] -= fil } } } pack.each{|v| 1.upto(3){|y| 0.upto(2){|x| print (y <= v[x]) ? '#' : '.' } puts "" } } puts "" # 末尾の改行はしているはずだけれども念のため puts "" # 心配だからもう1個 puts "" # まだ不安? puts "" # ・・・