結果

問題 No.1330 Multiply or Divide
ユーザー marroncastlemarroncastle
提出日時 2021-01-20 19:52:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 883 ms / 2,000 ms
コード長 462 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 107,752 KB
最終ジャッジ日時 2023-08-24 23:51:05
合計ジャッジ時間 10,060 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
71,528 KB
testcase_01 AC 205 ms
107,752 KB
testcase_02 AC 96 ms
71,640 KB
testcase_03 AC 96 ms
71,512 KB
testcase_04 AC 99 ms
71,424 KB
testcase_05 AC 97 ms
71,572 KB
testcase_06 AC 137 ms
106,100 KB
testcase_07 AC 883 ms
107,568 KB
testcase_08 AC 165 ms
102,056 KB
testcase_09 AC 166 ms
102,364 KB
testcase_10 AC 164 ms
102,156 KB
testcase_11 AC 162 ms
102,180 KB
testcase_12 AC 165 ms
102,348 KB
testcase_13 AC 96 ms
71,420 KB
testcase_14 AC 98 ms
71,316 KB
testcase_15 AC 96 ms
71,440 KB
testcase_16 AC 96 ms
71,708 KB
testcase_17 AC 97 ms
71,548 KB
testcase_18 AC 152 ms
102,012 KB
testcase_19 AC 151 ms
101,796 KB
testcase_20 AC 152 ms
101,944 KB
testcase_21 AC 151 ms
101,728 KB
testcase_22 AC 152 ms
101,780 KB
testcase_23 AC 158 ms
101,960 KB
testcase_24 AC 95 ms
71,652 KB
testcase_25 AC 96 ms
71,500 KB
testcase_26 AC 98 ms
71,596 KB
testcase_27 AC 96 ms
71,420 KB
testcase_28 AC 97 ms
71,528 KB
testcase_29 AC 98 ms
71,320 KB
testcase_30 AC 97 ms
71,684 KB
testcase_31 AC 98 ms
71,688 KB
testcase_32 AC 95 ms
71,672 KB
testcase_33 AC 96 ms
71,728 KB
testcase_34 AC 134 ms
101,836 KB
testcase_35 AC 112 ms
82,720 KB
testcase_36 AC 129 ms
98,848 KB
testcase_37 AC 127 ms
96,480 KB
testcase_38 AC 119 ms
87,916 KB
testcase_39 AC 112 ms
82,912 KB
testcase_40 AC 116 ms
85,908 KB
testcase_41 AC 109 ms
80,940 KB
testcase_42 AC 127 ms
94,792 KB
testcase_43 AC 127 ms
96,924 KB
testcase_44 AC 334 ms
106,044 KB
testcase_45 AC 408 ms
105,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M, P = map(int, input().split())
A = list(map(int, input().split()))
maxa = max(A)
from collections import defaultdict
dp = defaultdict(lambda: 0)
cnts = [1]*N
for i in range(N):
  while A[i]%P==0:
    cnts[i] += 1
    A[i] //= P
dp[0] = 1
if max(A)==1 and maxa<=M:
  print(-1)
  exit()
ans = 0
p = 1
while p*maxa <= M:
  for i in range(N):
    dp[ans+cnts[i]] = max(dp[ans+cnts[i]], p*A[i])
  ans += 1
  p = dp[ans]
if p>M:
  print(ans)
else:
  print(ans+1)
0