結果

問題 No.884 Eat and Add
ユーザー maimai
提出日時 2019-09-13 22:21:16
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 377 bytes
コンパイル時間 369 ms
コンパイル使用メモリ 11,472 KB
実行使用メモリ 28,492 KB
最終ジャッジ日時 2023-09-17 14:41:07
合計ジャッジ時間 3,383 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,088 KB
testcase_01 AC 81 ms
15,120 KB
testcase_02 AC 81 ms
15,000 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 205 ms
28,236 KB
testcase_08 AC 192 ms
28,240 KB
testcase_09 AC 203 ms
28,492 KB
testcase_10 AC 81 ms
15,212 KB
testcase_11 AC 81 ms
15,148 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'
    elsif c == '1'
        tw = la == '1'
        la = '1'
    end
end
total += tw ? (dc ? 1 : 2) : 1

p total
0