結果
問題 | No.1330 Multiply or Divide |
ユーザー |
|
提出日時 | 2021-01-08 23:08:55 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,701 ms / 2,000 ms |
コード長 | 540 bytes |
コンパイル時間 | 1,108 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 119,808 KB |
最終ジャッジ日時 | 2024-11-16 19:29:18 |
合計ジャッジ時間 | 30,791 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 46 |
ソースコード
N,M,P = map(int,input().split()) A = list(map(int,input().split())) B = [] for a in A: cost = 1 while a%P==0: a //= P cost += 1 if a!=1: B.append((cost,a)) n = len(B) dp = [1 for i in range(701)] for i in range(n): cost,a = B[i] next = [dp[j] for j in range(701)] for j in range(701-cost): next[j+cost] = max(next[j+cost],min(M+1,dp[j]*a),min(M+1,next[j]*a)) dp = next K = max(A) for i in range(701): if dp[i]*K >= M+1: print(i+1) break else: print(-1)