結果
問題 |
No.1956 猫の額
|
ユーザー |
![]() |
提出日時 | 2025-06-12 12:52:20 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,076 bytes |
コンパイル時間 | 285 ms |
コンパイル使用メモリ | 82,248 KB |
実行使用メモリ | 284,620 KB |
最終ジャッジ日時 | 2025-06-12 12:53:00 |
合計ジャッジ時間 | 9,012 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | MLE * 21 |
ソースコード
import sys from collections import defaultdict def main(): input = sys.stdin.read().split() idx = 0 N = int(input[idx]); idx += 1 M = int(input[idx]); idx += 1 C = int(input[idx]); idx += 1 A = list(map(int, input[idx:idx+N])) sumA = sum(A) dp = [defaultdict(int) for _ in range(C+1)] dp[0][0] = 1 # Initially, 0 elements selected, sum 0 for a in A: for j in range(C, -1, -1): current = dp[j] if not current: continue next_j = j + 1 if next_j > C: continue next_dict = dp[next_j] for k in list(current.keys()): new_k = k + a if new_k > sumA: continue next_dict[new_k] = (next_dict[new_k] + current[k]) % M result = [] for s in range(1, sumA + 1): if s < C: result.append(0) else: result.append(dp[C].get(s, 0) % M) print(' '.join(map(str, result))) if __name__ == '__main__': main()