結果

問題 No.884 Eat and Add
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-05-09 22:40:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 107 ms / 1,000 ms
コード長 284 bytes
コンパイル時間 1,562 ms
コンパイル使用メモリ 86,540 KB
実行使用メモリ 95,364 KB
最終ジャッジ日時 2023-09-24 03:26:30
合計ジャッジ時間 3,854 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,292 KB
testcase_01 AC 74 ms
71,108 KB
testcase_02 AC 71 ms
71,444 KB
testcase_03 AC 107 ms
95,296 KB
testcase_04 AC 104 ms
95,180 KB
testcase_05 AC 105 ms
95,184 KB
testcase_06 AC 105 ms
95,264 KB
testcase_07 AC 98 ms
95,120 KB
testcase_08 AC 100 ms
94,948 KB
testcase_09 AC 103 ms
95,364 KB
testcase_10 AC 74 ms
71,268 KB
testcase_11 AC 73 ms
71,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = list(map(int,input()))[::-1] + [0]
inf = 10**10
dp = [0,inf]

for b in n:
    ndp = [inf,inf]
    if b == 0:
        ndp[0] = min(dp[0],dp[1]+1)
        ndp[1] = dp[1]+1
    else:
        ndp[0] = dp[0]+1
        ndp[1] = min(dp[0]+1,dp[1])
    dp = ndp
print(min(dp[0],dp[1]+1))
0