結果

問題 No.3502 GCD Knapsack
コンテスト
ユーザー flippergo
提出日時 2026-06-02 09:05:51
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 901 ms / 2,000 ms
+ 974µs
コード長 477 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 81 ms
コンパイル使用メモリ 64,472 KB
実行使用メモリ 99,708 KB
最終ジャッジ日時 2026-10-17 03:40:31
合計ジャッジ時間 15,739 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

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