結果

問題 No.884 Eat and Add
ユーザー stngstng
提出日時 2022-08-07 17:28:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 324 bytes
コンパイル時間 1,272 ms
コンパイル使用メモリ 81,568 KB
実行使用メモリ 62,180 KB
最終ジャッジ日時 2023-10-17 12:16:56
合計ジャッジ時間 1,567 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,328 KB
testcase_01 AC 37 ms
53,328 KB
testcase_02 AC 37 ms
53,328 KB
testcase_03 AC 48 ms
62,156 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 48 ms
62,156 KB
testcase_07 AC 44 ms
60,084 KB
testcase_08 AC 43 ms
60,024 KB
testcase_09 AC 44 ms
60,032 KB
testcase_10 AC 38 ms
53,328 KB
testcase_11 AC 37 ms
53,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = "0"+"0"+input()
ans = 0
ln = len(n)
oc = 0
zc = 0
for i in range(ln-1,-1,-1):
    if n[i] == "1":
        oc += 1
    else:
        if i != ln-1 and n[i+1] == "0":
            ans += min(oc,zc+1)
            zc = 0
            oc = 0
        else:
            zc += 1
    #print(oc,zc,i)

#ans += min(oc,zc+2)
print(ans)
0