結果
| 問題 |
No.1330 Multiply or Divide
|
| コンテスト | |
| ユーザー |
brthyyjp
|
| 提出日時 | 2022-02-03 15:39:16 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 269 ms / 2,000 ms |
| コード長 | 559 bytes |
| コンパイル時間 | 157 ms |
| コンパイル使用メモリ | 82,208 KB |
| 実行使用メモリ | 116,504 KB |
| 最終ジャッジ日時 | 2025-06-20 01:38:55 |
| 合計ジャッジ時間 | 6,718 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 51 |
ソースコード
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)
N = 3000
dp = [0]*(N+1)
dp[0] = 1
for c, a in C.items():
for i in range(N+1):
if i+c <= N:
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