結果
| 問題 | No.3502 GCD Knapsack |
| コンテスト | |
| ユーザー |
uselessman
|
| 提出日時 | 2026-04-19 08:41:38 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 862 ms / 2,000 ms |
| コード長 | 480 bytes |
| 記録 | |
| コンパイル時間 | 127 ms |
| コンパイル使用メモリ | 85,248 KB |
| 実行使用メモリ | 124,996 KB |
| 最終ジャッジ日時 | 2026-04-19 08:42:07 |
| 合計ジャッジ時間 | 14,816 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
ソースコード
from math import gcd
from collections import defaultdict
def divisors(x):
ret = []
i = 1
while (i**2 <= x):
if x%i == 0:
ret.append(i)
if i != x//i:
ret.append(x//i)
i += 1
return ret
n,w = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
d = defaultdict(int)
for xi,yi in zip(x,y):
for p in divisors(xi):
d[p] += yi
ans = 0
for ky,vl in d.items():
if ky >= w:
ans = max(vl,ans)
print(ans)
uselessman