結果
問題 | No.1330 Multiply or Divide |
ユーザー |
![]() |
提出日時 | 2021-01-08 22:11:52 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 745 bytes |
コンパイル時間 | 504 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 283,996 KB |
最終ジャッジ日時 | 2024-04-28 03:25:39 |
合計ジャッジ時間 | 6,216 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 67 ms
71,296 KB |
testcase_01 | AC | 106 ms
108,416 KB |
testcase_02 | AC | 39 ms
51,712 KB |
testcase_03 | AC | 836 ms
81,144 KB |
testcase_04 | AC | 39 ms
52,096 KB |
testcase_05 | AC | 617 ms
80,544 KB |
testcase_06 | AC | 87 ms
98,688 KB |
testcase_07 | AC | 194 ms
108,140 KB |
testcase_08 | TLE | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
ソースコード
def main(n,m,p,a): ma0=max(a) if ma0>m:return 1 b=[1]*n for i in range(n): while a[i]%p==0: a[i]//=p b[i]+=1 ma1=max(a) if ma1==1: print(-1) exit() ary=[0]*30 for i in range(n): ary[b[i]]=max(ary[b[i]],a[i]) ary=[[i,v] for i,v in enumerate(ary) if v!=0] from heapq import heappush,heappop todo=[[0,1]] inf=float('inf') seen=[0]*1000 seen[0]=1 # seen[i]:操作回数i回における最大 while todo: i,v=heappop(todo) for di,dv in ary: if i+di<1000 and seen[i+di]<v*dv: seen[i+di]=v*dv heappush(todo,[i+di,v*dv]) for i in range(1000): if seen[i]*ma0>m:return i+1 n,m,p=map(int,input().split()) a=list(map(int,input().split())) print(main(n,m,p,a))