結果

問題 No.884 Eat and Add
ユーザー kawap23kawap23
提出日時 2019-09-13 22:45:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 564 bytes
コンパイル時間 438 ms
コンパイル使用メモリ 10,944 KB
実行使用メモリ 11,064 KB
最終ジャッジ日時 2023-09-17 14:55:26
合計ジャッジ時間 2,265 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,896 KB
testcase_01 AC 16 ms
7,900 KB
testcase_02 AC 16 ms
7,864 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 150 ms
10,940 KB
testcase_08 AC 218 ms
10,916 KB
testcase_09 AC 194 ms
11,032 KB
testcase_10 AC 15 ms
7,864 KB
testcase_11 AC 15 ms
7,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = ['0'] + list(input()) + ['0']
# print (N)
n = len(N)
ans = 0
tmp = n - 2
count = 0
while tmp >= 1:
    if N[tmp] == N[tmp - 1] == '0': #2連続0の時、区切れる
        ans += min(count, 2)
        count = 0
    elif N[tmp - 1] == '0' and N[tmp] == '1' and count == 0:
        ans += 1
    elif N[tmp - 1] == '0' and N[tmp] == '1' and count != 0:
        count += 1
    elif N[tmp - 1] == N[tmp] == '1' and count == 0:
        count = 1
    elif N[tmp - 1] == N[tmp] == '1' and count == 1:
        count = 1
    tmp -= 1

ans += count
print (ans)
        
0