結果

問題 No.3711 Udon, Tempura
コンテスト
ユーザー AP25
提出日時 2026-09-11 22:15:40
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 202 ms / 2,000 ms
+ 549µs
コード長 417 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 86 ms
コンパイル使用メモリ 80,768 KB
実行使用メモリ 110,336 KB
最終ジャッジ日時 2026-09-11 22:15:45
合計ジャッジ時間 4,154 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N, M = map(int, input().split())
U = set(map(int, input().split()))
T = list(map(int, input().split()))

tmax = sum(T)
dp = [False] * (tmax +1)
dp[0] = True

for t in T:
    for cur in range(tmax, t-1, -1):
        dp[cur] = dp[cur] | dp[cur-t]

G = set()
for i in range(tmax+1):
    if dp[i]:
        G.add(i)

ans = set()
for u in U:
    for g in G:
        ans.add(u+g)

print(len(ans))


0