結果
問題 |
No.1631 Sorting Integers (Multiple of K) Easy
|
ユーザー |
![]() |
提出日時 | 2025-06-12 13:45:38 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 702 bytes |
コンパイル時間 | 225 ms |
コンパイル使用メモリ | 82,616 KB |
実行使用メモリ | 80,220 KB |
最終ジャッジ日時 | 2025-06-12 13:46:29 |
合計ジャッジ時間 | 5,880 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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))