結果

問題 No.1782 ManyCoins
コンテスト
ユーザー ytft
提出日時 2022-02-17 12:53:04
言語 Python3
(3.14.3 + numpy 2.4.2 + scipy 1.17.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 480 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 395 ms
コンパイル使用メモリ 20,568 KB
実行使用メモリ 76,088 KB
最終ジャッジ日時 2026-03-18 18:24:10
合計ジャッジ時間 61,921 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 WA * 20 TLE * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import deque
N,L=map(int,input().split())
W=list(map(int,input().split()))
W.sort()
dist=[-1 for i in range(W[N-1])]
dist[0]=0
q=deque([0])
while len(q):
	i=q.pop()
	for j in range(N-1):
		if dist[(i+W[j])%W[N-1]]==-1:
			if i+W[j]<W[N-1]:
				dist[(i+W[j])%W[N-1]]=dist[i]
				q.append((i+W[j])%W[N-1])
			else:
				dist[(i+W[j])%W[N-1]]=dist[i]+1
				q.appendleft((i+W[j])%W[N-1])
ans=L
for i in range(W[N-1]):
	ans-=min(dist[i],max(L-i,0)//W[N-1]+1)
print(ans)
0