結果
| 問題 |
No.1633 Sorting Integers (Multiple of 2^K)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-12-20 23:43:47 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 690 bytes |
| コンパイル時間 | 207 ms |
| コンパイル使用メモリ | 82,168 KB |
| 実行使用メモリ | 76,800 KB |
| 最終ジャッジ日時 | 2024-09-27 10:16:35 |
| 合計ジャッジ時間 | 4,440 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 24 |
ソースコード
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)