結果
| 問題 |
No.1330 Multiply or Divide
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-08 22:57:27 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 528 bytes |
| コンパイル時間 | 234 ms |
| コンパイル使用メモリ | 81,928 KB |
| 実行使用メモリ | 120,024 KB |
| 最終ジャッジ日時 | 2024-11-16 14:54:34 |
| 合計ジャッジ時間 | 36,049 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 36 WA * 9 TLE * 1 |
ソースコード
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))
if not B:
exit(print(-1))
n = len(B)
dp = [1 for i in range(901)]
for i in range(n):
cost,a = B[i]
next = [dp[j] for j in range(901)]
for j in range(901-cost):
next[j+cost] = max(next[j+cost],min(M,dp[j]*a),min(M,next[j]*a))
dp = next
for i in range(901):
if dp[i]==M:
print(i)
break