結果

問題 No.3502 GCD Knapsack
コンテスト
ユーザー kitatai
提出日時 2026-04-18 12:07:46
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 663 ms / 2,000 ms
コード長 399 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 330 ms
コンパイル使用メモリ 85,072 KB
実行使用メモリ 119,680 KB
最終ジャッジ日時 2026-04-18 12:08:08
合計ジャッジ時間 16,706 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N, W = map(int, input().split())

X = list(map(int, input().split()))
Y = list(map(int, input().split()))

l = [0] * (2 * 10**5 + 1)

for x, y in zip(X, Y):
    i = 1
    # print(x)
    while i * i <= x:
        if x % i == 0:
            l[i] += y
            l[x // i] += y
        i += 1
max_l = -1
for i in range(W + 1, len(l)):
    if max_l < l[i]:
        max_l = l[i]
print(max_l)
# print(l)
0