結果

問題 No.3502 GCD Knapsack
コンテスト
ユーザー LyricalMaestro
提出日時 2026-04-18 20:37:18
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 116 ms / 2,000 ms
+ 537µs
コード長 634 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 79 ms
コンパイル使用メモリ 64,644 KB
実行使用メモリ 97,044 KB
最終ジャッジ日時 2026-10-17 03:23:15
合計ジャッジ時間 7,264 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

## https://yukicoder.me/problems/no/3502




def main():
    N, W = map(int, input().split())
    X = list(map(int, input().split()))
    Y = list(map(int, input().split()))

    max_w = max(W, max(X))
    x_map = [0 for _ in range(max_w + 1)]
    for i in range(N):
        x = X[i]
        y = Y[i]
        x_map[x] += y

    answer = [0] * (max_w + 1)
    for x in reversed(range(1, max_w + 1)):
        y = x
        while y <= max_w:
            answer[x] += x_map[y]
            y += x

    ans = 0
    for w in range(W, max_w + 1):
        ans = max(ans, answer[w])
    print(ans)









if __name__ == "__main__":
    main()
0