結果

問題 No.3502 GCD Knapsack
コンテスト
ユーザー ,
提出日時 2026-04-18 20:33:07
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 185 ms / 2,000 ms
+ 992µs
コード長 477 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 53 ms
コンパイル使用メモリ 14,976 KB
実行使用メモリ 40,816 KB
最終ジャッジ日時 2026-09-08 21:09:37
合計ジャッジ時間 8,900 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline

def solve():
    n, w = map(int, input().split())
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))

    mx = max(x)
    val = [0] * (mx + 1)

    for i in range(n):
        val[x[i]] += y[i]

    ans = 0

    for g in range(w, mx + 1):
        s = 0
        for v in range(g, mx + 1, g):
            s += val[v]
        if s > ans:
            ans = s

    print(ans)

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