結果

問題 No.884 Eat and Add
ユーザー maimai
提出日時 2019-09-13 22:16:39
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 367 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 11,172 KB
実行使用メモリ 28,432 KB
最終ジャッジ日時 2023-09-17 14:36:12
合計ジャッジ時間 2,874 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,132 KB
testcase_01 AC 82 ms
15,176 KB
testcase_02 AC 82 ms
15,076 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 207 ms
28,360 KB
testcase_08 AC 174 ms
28,404 KB
testcase_09 AC 191 ms
28,432 KB
testcase_10 AC 79 ms
15,048 KB
testcase_11 AC 79 ms
15,316 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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