結果
| 問題 |
No.1631 Sorting Integers (Multiple of K) Easy
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 18:46:30 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 702 bytes |
| コンパイル時間 | 198 ms |
| コンパイル使用メモリ | 82,312 KB |
| 実行使用メモリ | 318,804 KB |
| 最終ジャッジ日時 | 2025-06-12 18:46:41 |
| 合計ジャッジ時間 | 5,825 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 10 TLE * 1 -- * 17 |
ソースコード
from collections import defaultdict
n, k = map(int, input().split())
c = list(map(int, input().split()))
original = tuple(c)
dp = defaultdict(int)
initial_remainder = 0
dp[(initial_remainder, original)] = 1
for _ in range(n):
new_dp = defaultdict(int)
for (rem, counts), cnt in dp.items():
for i in range(9):
if counts[i] == 0:
continue
digit = i + 1
new_rem = (rem * 10 + digit) % k
new_counts = list(counts)
new_counts[i] -= 1
new_counts_tuple = tuple(new_counts)
new_dp[(new_rem, new_counts_tuple)] += cnt
dp = new_dp
all_zero = tuple([0] * 9)
print(dp.get((0, all_zero), 0))
gew1fw