結果

問題 No.154 市バス
ユーザー gigurururugigurururu
提出日時 2015-02-18 00:51:13
言語 Ruby
(3.3.0)
結果
AC  
実行時間 448 ms / 2,000 ms
コード長 348 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 13,312 KB
最終ジャッジ日時 2024-04-21 07:56:32
合計ジャッジ時間 4,593 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 430 ms
13,184 KB
testcase_01 AC 440 ms
13,312 KB
testcase_02 AC 443 ms
13,312 KB
testcase_03 AC 403 ms
13,056 KB
testcase_04 AC 448 ms
13,184 KB
testcase_05 AC 79 ms
12,160 KB
testcase_06 AC 81 ms
12,032 KB
testcase_07 AC 437 ms
13,312 KB
testcase_08 AC 81 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

puts $<.drop(1).map{|s|
  a=s.reverse.chars.inject([0,0,0]){|(r,g,w),c|
    case c
    when ?R
      r+=1
    when ?G
      break if r==0
      r-=1
      g+=1
    when ?W
      if g>0
        g-=1
        w+=1
      elsif w>0
        w+=1
      else
        break
      end
    end
    [r,g,w]
  }
  (a&&a[0]==0&&a[1]==0)?"possible":"impossible"
}
0