結果

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

ソースコード

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