結果

問題 No.1694 ZerOne
ユーザー KudeKude
提出日時 2021-10-01 21:58:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 487 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 87,032 KB
実行使用メモリ 76,452 KB
最終ジャッジ日時 2023-09-26 17:14:17
合計ジャッジ時間 4,422 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,288 KB
testcase_01 AC 74 ms
71,468 KB
testcase_02 AC 71 ms
71,200 KB
testcase_03 AC 82 ms
76,056 KB
testcase_04 AC 73 ms
71,236 KB
testcase_05 AC 81 ms
76,048 KB
testcase_06 AC 71 ms
71,060 KB
testcase_07 AC 78 ms
75,752 KB
testcase_08 AC 82 ms
75,904 KB
testcase_09 AC 81 ms
76,384 KB
testcase_10 AC 78 ms
75,748 KB
testcase_11 AC 72 ms
71,240 KB
testcase_12 AC 71 ms
71,036 KB
testcase_13 AC 83 ms
76,292 KB
testcase_14 AC 84 ms
76,236 KB
testcase_15 AC 79 ms
76,064 KB
testcase_16 AC 80 ms
75,760 KB
testcase_17 AC 76 ms
71,324 KB
testcase_18 AC 74 ms
71,044 KB
testcase_19 AC 70 ms
71,328 KB
testcase_20 AC 71 ms
71,448 KB
testcase_21 AC 72 ms
71,036 KB
testcase_22 AC 75 ms
75,972 KB
testcase_23 AC 74 ms
75,708 KB
testcase_24 AC 84 ms
76,304 KB
testcase_25 AC 83 ms
76,396 KB
testcase_26 AC 79 ms
76,228 KB
testcase_27 AC 79 ms
75,764 KB
testcase_28 AC 83 ms
76,060 KB
testcase_29 AC 74 ms
71,340 KB
testcase_30 AC 84 ms
76,276 KB
testcase_31 AC 85 ms
76,452 KB
testcase_32 AC 83 ms
76,448 KB
testcase_33 AC 83 ms
76,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input()
d = []
now = 0
for c in s:
    if c == '0':
        d.append(now)
        now = 0
    else:
        now += 1
d.append(now)

n = len(d)
m = sum(d)
tot = sum(i * x for i, x in enumerate(d))
# dp[used][sum]
dp = [[0] * (tot + 1) for _ in range(m + 1)]
dp[0][0] = 1
for i in range(n):
    for j in range(m):
        for k in range(tot + 1):
            nj = j + 1
            nk = k + i
            if nk <= tot:
                dp[nj][nk] += dp[j][k]
ans = dp[-1][-1]
print(ans)
0