結果

問題 No.3502 GCD Knapsack
コンテスト
ユーザー flippergo
提出日時 2026-06-02 09:05:51
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 384 ms / 2,000 ms
コード長 477 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 341 ms
コンパイル使用メモリ 85,632 KB
実行使用メモリ 143,932 KB
最終ジャッジ日時 2026-06-02 09:06:08
合計ジャッジ時間 13,045 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_1
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from bisect import bisect_left
N,W = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
C = {}
for i in range(N):
    x = X[i]
    y = Y[i]
    C[x] = C.get(x,0)+y
C = sorted(C.items())
xmin = C[0][0]
xmax = C[-1][0]
ans = 0
for w in range(W,xmax+1):
    cnt = 0
    for k in range(1,xmax//w+1):
        x = w*k
        i = bisect_left(C, (x,0))
        if C[i][0]==x:
            cnt += C[i][1]
    ans = max(ans, cnt)
print(ans)
0