結果

問題 No.884 Eat and Add
ユーザー mai
提出日時 2019-09-13 22:21:16
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 377 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 27,776 KB
最終ジャッジ日時 2024-07-04 09:56:22
合計ジャッジ時間 2,899 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 WA * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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

la = '0'
total = 0
tw = false
dc = false
gets.chomp.reverse.chars.each do |c|
    if c == '0'
        total += tw ? (dc ? 1 : 2) : 1 if la == '1'
        dc = false if la == '0'
        dc = true  if la == '1'
        la = '0'
    elsif c == '1'
        tw = la == '1'
        la = '1'
    end
end
total += tw ? (dc ? 1 : 2) : 1

p total
0