結果

問題 No.1633 Sorting Integers (Multiple of 2^K)
ユーザー 👑 rin204rin204
提出日時 2023-12-20 23:43:47
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 690 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,208 KB
最終ジャッジ日時 2023-12-20 23:43:52
合計ジャッジ時間 5,339 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 36 ms
53,460 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 37 ms
53,460 KB
testcase_06 AC 37 ms
53,460 KB
testcase_07 AC 39 ms
53,460 KB
testcase_08 AC 37 ms
53,460 KB
testcase_09 AC 36 ms
53,460 KB
testcase_10 AC 36 ms
53,460 KB
testcase_11 AC 37 ms
53,460 KB
testcase_12 AC 36 ms
53,460 KB
testcase_13 AC 39 ms
53,460 KB
testcase_14 AC 37 ms
53,460 KB
testcase_15 AC 36 ms
53,460 KB
testcase_16 AC 39 ms
53,460 KB
testcase_17 AC 38 ms
53,460 KB
testcase_18 AC 37 ms
53,460 KB
testcase_19 AC 38 ms
53,460 KB
testcase_20 AC 38 ms
53,460 KB
testcase_21 AC 38 ms
53,460 KB
testcase_22 AC 36 ms
53,460 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 36 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
C = list(map(int, input().split()))
A = []
for i, c in enumerate(C, 1):
    A += [i] * c

memo = {}


def f(bit, tot, t, x, ten):
    if tot % x != 0:
        return 0
    if t == n:
        c = 0
        while tot % 2 == 0:
            tot >>= 1
            c += 1
        return c

    tmp = bit * n + t
    if tmp in memo:
        return memo[tmp]

    ret = t
    for i in range(n):
        if not bit >> i & 1:
            if i > 0 and A[i - 1] == A[i] and not (bit >> (i - 1) & 1):
                continue
            ret = max(ret, f(bit ^ (1 << i), A[i] * ten + tot, t + 1, x * 2, ten * 10))

    memo[tmp] = ret
    return ret


ans = f(0, 0, 0, 1, 1)
print(ans)
0