結果

問題 No.884 Eat and Add
ユーザー mai
提出日時 2019-09-13 22:16:39
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 367 bytes
コンパイル時間 39 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 27,776 KB
最終ジャッジ日時 2024-07-04 09:52:53
合計ジャッジ時間 2,734 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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'
    else
        tw = la == '1'
        la = '1'
    end
end
total += tw ? (dc ? 1 : 2) : 1

p total
0