結果
| 問題 |
No.1330 Multiply or Divide
|
| コンテスト | |
| ユーザー |
brthyyjp
|
| 提出日時 | 2022-02-03 15:26:47 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 549 bytes |
| コンパイル時間 | 144 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 107,264 KB |
| 最終ジャッジ日時 | 2024-06-11 09:56:41 |
| 合計ジャッジ時間 | 4,768 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 45 WA * 1 |
ソースコード
n, m, p = map(int, input().split())
A = list(map(int, input().split()))
from collections import defaultdict
C = defaultdict(lambda: 0)
D = []
for a in A:
b = a
cost = 1
while a%p == 0:
cost += 1
a //= p
C[cost] = max(C[cost], a)
M = max(A)
dp = [0]*101
dp[0] = 1
for c, a in C.items():
for i in range(101):
if i+c <= 100:
dp[i+c] = max(dp[i+c], dp[i]*a)
ans = 10**18
for i, x in enumerate(dp):
if x*M> m:
ans = min(ans, i+1)
if ans != 10**18:
print(ans)
else:
print(-1)
brthyyjp