結果
問題 |
No.1956 猫の額
|
ユーザー |
![]() |
提出日時 | 2025-06-12 20:49:49 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 810 bytes |
コンパイル時間 | 321 ms |
コンパイル使用メモリ | 82,768 KB |
実行使用メモリ | 114,336 KB |
最終ジャッジ日時 | 2025-06-12 20:53:29 |
合計ジャッジ時間 | 116,240 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | MLE * 21 |
ソースコード
def main(): import sys 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])) idx += N sum_A = sum(A) if C == 0: print(' '.join(['0'] * sum_A)) return # Initialize DP dp = [[0] * (sum_A + 1) for _ in range(C + 1)] dp[0][0] = 1 for a in A: for c in range(C, 0, -1): max_s = min(sum_A, sum_A - a) for s in range(sum_A, a - 1, -1): if s - a >= 0: dp[c][s] = (dp[c][s] + dp[c-1][s - a]) % M result = [] for s in range(1, sum_A + 1): result.append(str(dp[C][s] % M)) print(' '.join(result)) if __name__ == '__main__': main()