結果

問題 No.2063 ±2^k operations (easy)
ユーザー maguroflymagurofly
提出日時 2022-09-02 21:33:33
言語 Ruby
(3.2.2)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 252 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 11,264 KB
実行使用メモリ 15,916 KB
最終ジャッジ日時 2023-08-10 03:27:44
合計ジャッジ時間 3,583 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,008 KB
testcase_01 AC 80 ms
15,088 KB
testcase_02 AC 81 ms
15,320 KB
testcase_03 AC 82 ms
15,012 KB
testcase_04 AC 81 ms
15,084 KB
testcase_05 AC 80 ms
15,132 KB
testcase_06 AC 81 ms
15,172 KB
testcase_07 AC 81 ms
15,132 KB
testcase_08 AC 81 ms
15,116 KB
testcase_09 AC 81 ms
15,220 KB
testcase_10 AC 81 ms
15,140 KB
testcase_11 AC 80 ms
15,148 KB
testcase_12 AC 82 ms
15,352 KB
testcase_13 AC 81 ms
15,008 KB
testcase_14 AC 81 ms
15,300 KB
testcase_15 AC 80 ms
15,296 KB
testcase_16 AC 81 ms
15,104 KB
testcase_17 AC 104 ms
15,620 KB
testcase_18 AC 105 ms
15,440 KB
testcase_19 AC 101 ms
15,440 KB
testcase_20 AC 105 ms
15,512 KB
testcase_21 AC 107 ms
15,376 KB
testcase_22 AC 113 ms
15,916 KB
testcase_23 AC 114 ms
15,636 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.chomp
runs = []
prev = ?0
N.each_char do |c|
    if c == ?1
        if prev == ?1
            runs[-1] += 1
        else
            runs << 1
        end
    end
    prev = c
end

ans = runs.sum { |x| [x, 2].min }
puts ans == 2 ? "Yes" : "No"
0