結果
| 問題 |
No.1634 Sorting Integers (Multiple of K) Hard
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 15:51:06 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 932 bytes |
| コンパイル時間 | 159 ms |
| コンパイル使用メモリ | 82,236 KB |
| 実行使用メモリ | 709,400 KB |
| 最終ジャッジ日時 | 2025-06-12 15:51:27 |
| 合計ジャッジ時間 | 6,716 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 4 MLE * 1 -- * 23 |
ソースコード
import sys
from collections import defaultdict
def main():
N, K = map(int, sys.stdin.readline().split())
c = list(map(int, sys.stdin.readline().split()))
# Initial state: remainder 0, counts all 0, ways = 1
dp = defaultdict(int)
initial_counts = tuple([0]*9)
dp[(0, initial_counts)] = 1
for pos in range(N):
next_dp = defaultdict(int)
for (rem, counts), ways in dp.items():
for d in range(9):
if counts[d] < c[d]:
new_counts = list(counts)
new_counts[d] += 1
new_counts = tuple(new_counts)
new_rem = (rem * 10 + (d + 1)) % K
next_dp[(new_rem, new_counts)] += ways
dp = next_dp
total = 0
for (rem, counts), ways in dp.items():
if rem == 0:
total += ways
print(total)
if __name__ == '__main__':
main()
gew1fw